Gallery block: Add css var to enable theme authors to set a default gallery gap#40008
Gallery block: Add css var to enable theme authors to set a default gallery gap#40008glendaviesnz merged 4 commits intotrunkfrom
Conversation
|
Size Change: +56 B (0%) Total Size: 1.22 MB
ℹ️ View Unchanged
|
|
@justintadlock - it looks like with a minor change to the way the block gap is being applied we can add a fallback to a css var. I am not sure if it is worth supporting both indefinitely. I wonder if we are better to make a clean switch to |
There was a problem hiding this comment.
This looks like a good path forward to me @glendaviesnz (tested that it appears to be using fallbacks correctly in the editor and on the frontend)! Nice idea incorporating the deprecated CSS variable. Just left a couple of minor comments about skipping serialization and the order of the CSS variables, but no real blockers there I don't think 🙂
This all looks pretty good. I was definitely having trouble finding a way to set a default via CSS without a var. Theme authors should be able to provide compat for WP 5.9 and 6.0+ with something like this now: .wp-block-gallery {
--gallery-block--gutter-size: var( --wp--custom--spacing--4 );
--wp--style--gallery-gap-default: var( --wp--custom--spacing--4 );
}As for removal of the |
|
Thanks for taking the time to test this out @justintadlock - and for raising the concern in the first place - good to get this sorted ahead of 6.0.
Sounds like a good approach, let's go with that. |



What?
Adds back support for the deprecated
--gallery-block--gutter-sizecss var, and also support for a new--wp--style--gallery-gap-defaultcss var to allow theme authors to define a default gallery gap that can be overridden by any user applied gap.Why?
As noted here the recent change to add gap support was a breaking change for some themes as it removed the
--gallery-block--gutter-sizeand did not provide an alternative way for themes to define a default gap setting.How?
Disables the default serialization of the layout to allow it to be manually applied by the Gallery block allowing for fallbacks to any theme set css vars
Testing Instructions
Screenshots
Before:

After:
