-
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
Gallery block: Add css var to enable theme authors to set a default gallery gap #40008
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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?
Adds back support for the deprecated
--gallery-block--gutter-size
css var, and also support for a new--wp--style--gallery-gap-default
css 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-size
and 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: