-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Layout: Add default fallback gap value in block.json, and set to 2em for Columns blocks #41098
Changes from 2 commits
56152c6
a9dd741
a2cc158
426f67a
e779a9f
7774b7c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -33,6 +33,9 @@ | |||||
"padding": true, | ||||||
"__experimentalDefaultControls": { | ||||||
"padding": true | ||||||
}, | ||||||
"__experimentalDefaultValues": { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if it makes sense to use the proposed block.json changes from https://github.com/WordPress/gutenberg/pull/34180/files#diff-dba084b81a05295345ce9149af1a17ab073ddef43a393e851bcd3bdae85d3f32R81 for default values. (PR: Prototype: merge block CSS with theme.json styles #34180) I don't know how far that particular investigation will go, but it could save some lines to "join forces" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, neat idea! There's quite a lot of similarity here — for the case of I suppose the caveat here is that this PR will likely need to be backported to 6.0 RC whereas it looks like #34180 is a bit more forward-looking and something potentially for 6.1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Ah, very good point.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The individual feature properties of the
It'd be a more complex change to refactor those props to also support an object (with a nested
We could always rename this from
What do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also we'd have to find a model to define default side values too, right? Well, maybe not initially. Still that would involve some data massaging I suppose. "margin": [ "top", "bottom" ] To something like "margin": { default: { "top": "1em", ... } } 🤷
It's possibly not the cleanest way, but I guess we could check for the existence of a if (
! support ||
typeof support[ feature ] === 'boolean' ||
!! support?.[ feature ]?.default
) {
return;
} I'm not saying it's pretty, and I kinda also wonder if the complexity is worth it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, that's the one I was thinking about, since you can also do. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the feedback here! It turns out it wasn't as complex to deal with as I'd thought given that we only appear to look up which sides are opted into in the one place ( In a2cc158, I've gone with the approach of:
And we can also specify a |
||||||
"blockGap": "2em" | ||||||
} | ||||||
}, | ||||||
"__experimentalLayout": { | ||||||
|
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 about flow.js? no fallback support there?
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 noticed that too when I went to work on this feature — the Flow layout currently doesn't use any fallback value at all, so I didn't inject one where there isn't one already (both in
layout.php
andflow.js
). From looking over the code again, it appears that blockGap styles in the Flow layout are only ever output if the blockGap has been opted into, in which case there'll always be a value, so a fallback value will never be reached. E.g. in the following block:gutenberg/packages/block-editor/src/layouts/flow.js
Line 168 in 6de1698
It was the Flex layout that currently has a
0.5em
hard-coded fallback, and where I think this feature is useful based on the current implementations.But, please do let me know if I missed something here! 🙂