-
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
Add spacing presets support to style engine #41990
Add spacing presets support to style engine #41990
Conversation
3f5fd5b
to
1a04521
Compare
1a04521
to
f473509
Compare
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.
The PHP implementation is working nicely for me @glendaviesnz, but it looks like the JS implementation needs updating for the individual sides. At first glance, it might only be a couple of lines of code that needs to be changed?
In my local dev environment, I updated this line:
const value: string | undefined = get( boxStyle, [ side ] ); |
to be the following:
const value: string | undefined = getCSSVarFromStyleValue(
get( boxStyle, [ side ] )
);
And that seemed to do the trick. It might need a test or two added for the JS side of things 🙂
Editor view before (no padding is applied) | Editor view after (padding is applied) |
---|---|
Of course, you can always leave implementing the JS-side to a follow-up PR instead if you'd prefer to keep this one just focused on the PHP implementation for now. What do you think?
Thanks, I was just focusing on the frontend for this PR, thinking the editor side would be more complicated, but your suggested change works and is simple so have included it. |
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 handling of conversion of spacing preset values to css vars to style engine
Why?
#41527 adds the spacing presets to theme.json, as the first part of implementing standardised design tokens for spacing as detailed in #39371
How?
Extends the existing preset var handling added for the processing of color presets.
Testing Instructions
var:preset|space|20
values intovar(--wp--preset--spacing--20);
in the block stylesnpm run test-unit-php /var/www/html/wp-content/plugins/gutenberg/packages/style-engine/phpunit/class-wp-style-engine-test.php
N.B. The frontend styles markup in this PR is not an indication of the final marking for spacing presets. The final implementation may use utility classes as noted in #39371, but the fact that we are generating these styles dynamically on the frontend means we can modify the output relatively easily as we go.
Screenshots or screencast