-
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
Columns Block: Add custom gutter widths #27661
Conversation
Size Change: -15 B (0%) Total Size: 1.28 MB
ℹ️ View Unchanged
|
This tested well for me. My only question is with nested column blocks where parent gutter setting flows through to any child columns block that hasn't explicitly specified a gutter. Once a child explicitly sets the gutter size it does override the parent setting. This seems reasonable to me, but just wondering if it is the expected behaviour, or if it will confuse users at all when nesting columns? |
That is the nature of CSS, I don't think our users would have the same perspective though. I can see benefits either way. The UI doesn't really inform the user that the setting would cascade. In this case it might be better to require the gutter sizes to be explicitly set on the nested columns. I've made that change, let me know whether you think it's an improvement. |
To me this is now works more how you would expect, ie. changes a |
+1 for the setting not automatically applying to nested columns; I also think that feels more natural/how I would expect those settings to work as a user. This tested well for me. |
Until the new sidebar controls and system lands, it is preferred to avoid adding any new UI controls to the sidebar.
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.
Switch to code editor view and add a gutterSize attribute to the columns block along with a matching inline style. e.g. --columns-block-gutter-size: 0px;
What exactly should this look like in the code view? It's not clear.
Sorry about that. I'll update the test instructions with an explicit code example. The linked gist from step 6 also contains example block code with the attribute and inline style set.
|
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.
Thanks for the code snippet. This worked well for me. 👍
A new iteration of the block supports mechanism is under way (#28913). Those efforts aim to provide a means to target which inner elements get the block support style applied to them. With that functionality, the columns block could opt into a new spacing > margins block support feature and apply those styles to the inner columns. The current approach in this PR is relatively clean but does not offer the ability to set the gutter sizes via theme.json. I'll revisit this once the new iteration of block supports lands. |
Closing this PR. In some environments kses will strip out CSS custom properties from the saved post content. This means when the block is loaded again in the editor is will be deemed invalid. The new approach to applying block support styles to inner blocks is likely to be the best path forward for this. That is, once margins are added to the current spacing block support. |
Fixes: #10730
Description
Adds the ability to set custom gutter widths for a columns block via a new attribute and inline style.
No new UI control will be added until the new sidebar controls and component system is available.
How has this been tested?
Manually.
Testing Instructions
(it can help make the gutters more obvious if you add inner group blocks with a background color)
gutterSize
attribute to the columns block along with a matching inline style. e.g.--columns-block-gutter-size: 0px;
or simply copy and paste in the block code below:Screenshots
Types of changes
New feature.
Checklist: