Merged
Conversation
This was referenced Jan 26, 2021
39c2e8f to
64d06d6
Compare
Collaborator
Builds ready [64d06d6]
Page Load Metrics (589 ± 25 ms)
|
darkwing
approved these changes
Jan 27, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale
When bootstrapping new UI A non zero amount of time is spent writing basic CSS to position elements on the screen. The usual tools for doing this are wrapper divs that have combinations of flex properties, padding, and margin. This new component provides a utility for easily creating these sorts of wrappers.
I am aiming at the smallest API to support the known usages that I have for it at present, with the intention of expanding upon it gradually to support most use cases. I drew heavy inspiration from tailwind CSS on this one.
Examples
Box around an element
The box has a border with border radius, and margins and padding
Flex box example 1
Three children, each spaced evenly in the middle of the box. The box should consume half of it's parent's width and height. Apply a 3px border with UI1 color.
Flex box example 2
Three children, space placed between each element, aligned in the middle. The box should expand to the full height and width of the screen. Apply a 3px border with UI1 color.
Avoiding superfluous divs
The Box component does nothing, really, except computing
classNames. I thought of creating this as a function that spits out theseclassNamesthat could then be added to any element. I decided against that because it would create a misdirection in the component+style coupling in the filesystem we are currently doing.I also didn't want to encourage adding superfluous wrappers when the box classes could just be applied to another element that needs to use the margin/padding or other classes.
To that end,
<Box>will accept a functional child, the function is passed the computed box class names that can then be added to another component.Sizing System
The sizing system presented here is a general attempt to implement rudimentary sizing. This system is simple, and will not meet our needs at scale (of the usage of this system). I will accept change requests to the sizing system but note that I have already queued up a conversation about this in the component/design system sync. Including the original message: