RFC: Vertical and Horizontal Flow Component #292
Replies: 5 comments 1 reply
-
Grid makes more sense to me especially with the underlying primitive being css-grid. (Does this support IE 11? If not what's the fallback?) Row/Column might be good choices as well (however this might be ambiguous with other components specifically table)
I like different components because I think the API is clearer if they do end up with different api surfaces. If the api surface is the same I don't mind if they're the same. How do we expect people to have the correct width on these components (should this be handled by min-width?) Probably unsolvable through the api but a callout in docs with a preferred method might be wise. (should the default overflow be scroll or hidden?) |
Beta Was this translation helpful? Give feedback.
-
Open question for anybody: If you want to see this component in Paste, where do you imagine you'd use it? |
Beta Was this translation helpful? Give feedback.
-
In light of Max Stoiber's recent article validating my beliefs that components should not have outer margins by default, I'm definitely for this.
Yup
How about Spacer?
I think they can be two components from the same package, but we should play around with it for a bit to figure out what feels best.
/shrug |
Beta Was this translation helpful? Give feedback.
-
Short answer: No. Long answer: IMHO, it seems like an unnecessary level of abstraction. I would prefer that the containing component have control over where the children are displayed and often times that means writing custom styles to suite a particular design (as opposed to wrapping a style component around a set of components to then put in the containing component). Personally, don't love the idea of components just for styles; I'd rather see a set of utility classes that can be extended/included as needed. I'm 💯% for having guidelines for vertical and horizontal rhythms, but I don't think one component (or a couple) can realistically accommodate all possible use cases. Sidebar: As a newcomer to the Design Library discussion, is the ultimate goal to prevent engineers from ever having to write CSS? I understand the idea of having things be as consistent as possible across the brand. |
Beta Was this translation helpful? Give feedback.
-
To round this out, we shipped the Stack component. https://paste.twilio.design/layout/stack/ |
Beta Was this translation helpful? Give feedback.
-
Creating horizontal and vertical flow in UI
Problem
As an engineer, I often have to lay UI elements on a page in a stack or row with each element being evenly spaced. Right now, there are a few ways I can achieve this but they are fiddly and not easily repeatable.
Prior art
https://bold.bridge.ufsc.br/storybook/?path=/story/components-hflow--default and https://bold.bridge.ufsc.br/storybook/?path=/story/components-vflow--default
Constraints
No component should style things that it does not own. It might be easy to create a styled component that uses a descendant and/or pseudo selector that controls the margin of child elements but it's really not a good idea to apply styling to something that a consumer is providing. You have no idea of the side effects, and the upgrade path is dangerous as you might cause a breaking style change in the future.
This works, but you shouldn't do it, IMO;
Design
A
Flow
component that can create vertical or horizontal flow within a UI, by wrapping the elements you wish to "flow". It takes a spacing prop that allows you to apply a spacing token and the creates the gap or gutter between elements.Check the code here in an Experimental example
Considerations
Perf
The CSS approach is browser optimised. On extremely large lists of things, this will (I'm at least sure) always beats mapping over children in react.
Feedback wanted
Flow
a good name? Stack? Spacing?Beta Was this translation helpful? Give feedback.
All reactions