-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create FormLayout
component
#93
Conversation
@@ -19,7 +20,7 @@ const CardList = (props) => { | |||
className={styles.root} | |||
{...other} | |||
> | |||
{React.Children.map(children, (child) => { | |||
{flattenChildren(children).map((child) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fragments are not traversed with React.children.map()
[1][2] so I'm using the react-keyed-flatten-children
bundle to flatten the children to a one-dimensional array. This is necessary to be able to pass props to children of these layouts.
[1] https://reactjs.org/docs/react-api.html#reactchildrenmap
[2] reactjs/rfcs#61 (comment)
name="Vertical Form Layout" | ||
component={( | ||
<FormLayout> | ||
<> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an example of React.Fragment
that we need to be able to traverse for the Form Layout
to work even with form fields nested in fragments.
Nobody noticed the tests were missing? Shame on you! 🙂 |
Updates:
|
Fragments are not traversed with `React.children.map()` [1][2] so we are using the `react-keyed-flatten-children` bundle to flatten the children to a one-dimensional array. This is necessary to be able to pass props to children of these layouts. [1] https://reactjs.org/docs/react-api.html#reactchildrenmap [2] reactjs/rfcs#61 (comment)
FormLayout
component and make form fields ready for itCardList
andFormLayout
Closes #44.
Vertical Form Layout
With FF grid inspector on:
Horizontal Form Layout
Firefox – Subgrid Solution (auto-sized column with labels)
https://caniuse.com/#feat=css-subgrid
With FF grid inspector on:
Webkit – Fallback Solution (fixed-width column with labels)
Edge Cases
Label width is limited to 50 % of available horizontal space.