-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Update LayoutCard story in DataForm to use card layout #73695
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
Conversation
|
Warning: Type of PR label mismatch To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.
Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
|
||
| const form: Form = useMemo( | ||
| () => ( { | ||
| layout: { type: 'card' }, |
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 should not be necessary because every field declares its layout, and all the 3 top-level fields that create a card have card as the layout. That should be enough to match any styles. I'll take a look.
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.
Thank you.
In case it's not clear, this is about the spacing between the cards themselves (which should be 24px), not the fields within the cards (which should be 16px).
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.
The wrapper layout depends on the form.layout.type. If not present, we normalize it to the regular layout that uses 4 as spacing setting, while the card layout uses 6 (ref).
This is fragile. 🤔
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.
What if it was the individual fields (each card, each panel, each regular field) that set the spacing? Something along these lines:
<div class="container">
<div class="card">...</div>
<div class="panel">...</div>
<div class="regular">...</div>
</div>// DataForm CSS
.container {
display: flex;
flex-direction: column;
}
// The card layout's CSS
.card + * {
margin-top: 24px;
}
// The panel layout's CSS
.panel + * {
margin-top: 16px;
}
// The regular layout's CSS
.regular + * {
margin-top: 8px;
}Would there be any issue with this? We could remove all the wrappers from the existing layouts but the row one.
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.
Yes I think something along those lines might work. I made a CodePen to explore. The rules are a bit more specific to account for specific order combos but I think this covers everything neatly.
Do you think there are any trade-offs to using margin vs gap?
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.
@oandregal any thoughts on this?
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.
I've approved this PR, but we can continue the conversation.
I thought about this, but I've noticed we mix panel and regular items in a few places (QuickEdit, for example). If the field themselves provide the spacing, and each layout has its own, wouldn't this create different spacing between fields in the same form?
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.
Another thought is that we make it a card because we want the spacing of a card. The spacing applied between fields is overloaded with the layout type. A different approach could be 1) remove the top-level layout prop, it's the field responsibility to declare its own 2) and a top-level gap prop to configure the spacing between fields.
If we go this route, I suppose the best approach would be to connect this gap with the spacing from DS (e.g., "xs", "md").
I'm not sure how this got overlooked, but this PR is a small follow-up to #72249 which ensures the "LayoutCard" DataForm story uses the
cardlayout to ensure correct spacing between cards.Testing
Compare http://localhost:50240/?path=/story/dataviews-dataform--layout-card with https://wordpress.github.io/gutenberg/?path=/story/dataviews-dataform--layout-card and note that the gap between cards in the former is
24pxcompared to16pxin the latter.