feat(components): add Flex and Text primitives to components library #5637
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.
overview
This PR follows up on a comment I posted in Slack earlier today. It starts a primitives section in the components library that we can use to build other components a little more easily:
Flex
-div
withdisplay: flex
and props to set common flex stylesText
-p
with margins removed and props to set common text stylesAt least when I'm building components, a flex div and text of some sort are two of the most common (if not the most common) things I end up styling.
This PR also moves some styling constants to more common locations to make stuff easier to find and grok.
example usage
changelog
review requests
This is a very tiny step in starting to build common components that are hooked into a common theme / scales. It's pretty inspired by Theme UI's components and libraries like Rebass
To see what this looks like in practice, check out #5638. Also check out the component library sandbox:
https://s3-us-west-2.amazonaws.com/opentrons-components/components_primitives/index.html#section-primitives
reasoning
I've been playing around with these in practice, and I'm finding that these "presentational props" provide a very nice balance between flexibility and consistency.
as
prop to render as any other DOM element or componentcss
propstyled
className
future primitives / work
Link
primitive could be really handy, especially if it deals withtarget=blank
stuff (see FE Monorepo Projects: Centralize links #4229)Heading
variant ofText
could be goodButton
primitive?css
prop et al.risk assessment
Low. New components are not used yet nor are they even required to be used