-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Design Tools: Enhance Block Gap control to support axial configuration #34529
Comments
Thanks for writing up the tracking issue for the next steps on this one, Joen! There's a couple of challenges to exploring how we can split out the values. I'll add some dot-points here to hopefully lay out where things are at now for any of us who might pick up this task! Note: The thoughts below are a little rambling, and other folks might already have better ideas about how to handle this. In the shorter-term, I think it's a good idea to opt individual blocks into the existing single block gap value, and see if we can add in axial configuration in a follow-up as it could get a little complex trying to come up with a neat solution. Here's the current state of things:
For background, the CSS variable approach was chosen so that the blockGap UI can be consistent with how the layout support works (with gap introduced in #33812). Using a CSS variable also gives us the flexibility to have different blocks use different approaches for how they calculate the gap between elements. For example, with the single block gap support, we can have the Buttons block use So, we have some flexibility thanks to using the CSS variable, however right now we only have a single CSS variable, which doesn't give us access to separate horizontal and vertical values which we'd use for
In the above rule, we attempt to use the row gap variable it it's available, and if not fall back to using the single block gap variable, and if that's not available, we fall back to a real CSS value ( The main problem with the above approach is that if an individual block tries to use the grouped variable, but something further up the chain has set separate values, then the wrong CSS variable could be picked up instead. So, in individual block controls, we might need to always set the separate row/column variables. However, if we did that, how do we ensure that I'm keen to hear if anyone else has ideas about how we might support separate horizontal / vertical gap values in a neat way 🙂 |
I am thinking Isabel @tellthemachines Jorge @jorgefilipecosta and Andre @oandregal might have some CSS/Global and theme.json thoughts to share here. |
I'm also noting down some observations with no particular claim to expertise in this area 😄
I don't know if this is even possible, but would it be too complex to use the existing variable It's possible to set "styles": {
"spacing": { "blockGap": "24px 24px" }
} Which renders Could we not check for and use shorthand values in the block support gap hook and corresponding inline styles as well? For block supports, we could keep the axial nomenclature in There might be places where the application would have to be aware where a shorthand value is used, e.g., Individual blocks could always define their fallbacks like this (I think): .wp-block-navigation__container {
gap: var( --wp--style--block-gap, 2em 2em );
} I'm almost certainly missing crucial information as to why this wouldn't be possible 😆 and I also understand this could be regressive in the case of the Columns Block unless we figured out a way to apply the right value (row) to the margin in the case of the shorthand value 🤔 |
Pasting some interesting notes from a conversation with @andrewserong so we can refer to them as we explore this issue.
|
There are very likely learnings to be had for the UI as well, for any other theme.json properties which can be fed shorthand syntax. Margin and padding just to name a few. |
Here's another potential use case for splitting the blockGap values: #35778 |
I've closed Block spacing: add axial gap block support #35454 for now since we're not using CSS vars for block gap styles. ( See #37360 ) We could experiment with alternative ways to split values and pass them to the layouts/flex styles. Block-level exploration sans CSS var over here: #37736 |
Resolved by #37736 Feel free to reopen if there are outstanding issues |
What problem does this address?
#32366 adds a theme.json mechanism to provide a a
blockGap
value to space out items in a container. Spacing using gap has the benefit of letting you not worry about the first or last elements in a container, or complex nth-child margins in containers that wrap.#33991 added a basic UI for it, with a single CSS variable to begin with.
What is your proposed solution?
Like how the padding control offers axial controls, a similar interaction could be used to split the single
gap
value into acolumn-gap
androw-gap
:The control would still be subject to design improvements pending from #27331 work, but the primary interaction would be the same. Sucha control would benefit Navigation, Social Icons and Buttons block, as those get gap support (#34525, #34526, #34527).
The text was updated successfully, but these errors were encountered: