-
Notifications
You must be signed in to change notification settings - Fork 4.6k
DataForm: set spacing for regular and card layouts #72249
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
|
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. |
|
Flaky tests detected in 6615830. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18741236975
|
dinhtungdu
left a comment
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.
Codewises, it looks good to me. I can confirm the change in the updated story, too. Can you please update the DataViews readme file to mention the new spacing prop we're adding here?
| * Spacing between individual fields when using the regular layout. | ||
| * Defaults to 4. | ||
| */ | ||
| spacing?: number; |
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.
In addition to have different spacing per layout, do we also want the consumer to be able to change this setting? It's fine if we want, just checking because I thought we didn't.
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 don't think it hurts so long as we have smart defaults. I could see this being a foundation for a density option in the future. For example in the Block inspector we might want fields to be closer together than in admin settings pages because the container sizes are so different. It would be neat to have a system for handling that. Not a strong feeling though if we prefer to leave it out for now...
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 use cases you mention make sense, but it could also be automatic based on viewport size or some other trick? I worry that if we expose this setting, every screen that uses DataForm would use a different spacing. It's not a strong opinion, and I'll defer to you. If it's not something we immediately need, we can add it later for consumers to use (it's more difficult to remove it, even if we have breaking changes).
|
@oandregal I updated the spacing values but removed the ability for consumers to customise. Please feel free to push any changes in case anything is wrong. |
e5b4bf9 to
97c0e0b
Compare
| } ) => ( | ||
| <VStack | ||
| className="dataforms-layouts__wrapper" | ||
| spacing={ ( layout as any )?.spacing ?? 4 } |
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.
Apparently, https://github.com/WordPress/gutenberg/pull/72284/files#diff-1d824e9459e5eecc174c60bb790d3f6c5eb5bb4f83fb01ffe5e737bb91facb71R24 introduced some spacing prop already. It didn't work because the normalizedLayout didn't have them, so it's fine to remove them from here without considering a breaking change. cc @dinhtungdu for awareness.
oandregal
left a comment
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'm unable to test the storybook right now because there's an issue with it. Though the code respects the intent (setting custom spacing per layout).
76bc622 to
f657511
Compare
|
Thank you for taking this over @oandregal ❤️ |
f657511 to
4c50413
Compare
|
There was a conflict while trying to cherry-pick the commit to the wp/6.9 branch. Please resolve the conflict manually and create a PR to the wp/6.9 branch. PRs to wp/6.9 are similar to PRs to trunk, but you should base your PR on the wp/6.9 branch instead of trunk. |
|
There was a conflict, and it couldn't be backported to the |
|
Prepared the backport at #72656 |
|
This pull request was manually backported to the |
What?
spacingtoRegularLayout,CardLayout, and their normalized types.LayoutMixedstory to uselayout: { type: 'card', spacing: 6 }.Why?
How?
Testing
npm run storybook.Note
I had assistance from AI preparing this PR. Apologies if anything was butchered, but hopefully it communicates the idea and can serve as a starting point.