-
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
Generate classes and custom properties for global styles in the same way the post editor does #32766
Conversation
Size Change: +32 B (0%) Total Size: 1.04 MB
ℹ️ View Unchanged
|
Looks like the linter is complaining -- try running Otherwise, it's looking pretty good already (based on unit test coverage -- haven't tested manually yet). We should certainly include this with 10.9, but maybe also with another 10.8 release? And how about WP 5.8? |
afc834f
to
230f8b0
Compare
Ok. This is working fine in the site editor and front end. I've reduced the regexp to match lodash's kebabCase to the minimum and added tests that cover all the cases that I've found or were reported. |
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.
Based on the very good test coverage I think we can merge this PR with confidence it fixes the issues.
goal is to replicate lodash's kebabCase behaviour
d069a55
to
1b72e7a
Compare
…way the post editor does (#32766)
…way the post editor does (#32766)
…way the post editor does (#32766)
Cherry-picked to |
Fixes #32347
We generate CSS classes for presets in a few places -post editor, site editor, server- and we need them to behave all the same. This PR explores porting lodash's
kebabCase
to the server. It's also applied to the names of the CSS Custom Properties for coherence.Background
This is the second take to fix #32347 We first tried to remove lodash's
kebabCase
function in the client at #32352 but that caused some issues and had to revert the original PR at #32742How to test
In the front end:
settings.color.palette
) in itstheme.json
to contain edge cases (see this table and the tests at class-gutenberg-utils-test.php for inspiration). For example, set a slug toblack23white
.global-styles-inline-css
style tag are generated properly as well as the CSS Custom Properties. Following the example above, you should find the--wp--preset--color--black-23-white
var and the classeshas-black-23-white-color
, etc.In the site editor:
settings.color.palette
) in itstheme.json
to contain edge cases (see this table and the tests at class-gutenberg-utils-test.php for inspiration). For example, set a slug toblack23white
.--wp--preset--color--black-23-white
var and the classeshas-black-23-white-color
, etc.