-
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
Global styles: consolidate theme.json ref and URI resolution #64182
Global styles: consolidate theme.json ref and URI resolution #64182
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: +33 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
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.
I like this refactor, and it's testing well for me!
✅ theme.json
refs are working for me as on trunk
✅ relative paths to background images are working in the editor and background controls
✅ making user updates in global styles works as expected
My test site design could use a little work, though 😄
LGTM! 🚀
packages/block-editor/src/components/global-styles/test/utils.js
Outdated
Show resolved
Hide resolved
packages/block-editor/src/components/global-styles/use-global-styles-output.js
Show resolved
Hide resolved
Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com>
What?
Part of
Requirement for
Consolidate theme.json/global styles value resolution.
Why?
While laying the ground work for #64128, I noticed that much of the resolution code could be brought together.
Some theme.json/global styles paths need resolving:
Both these operations are performed every time the editor builds global styles CSS, however in two different locations:
getStylesDeclarations()
useGlobalStylesOutputWithConfig()
How?
This PR consolidates resolution logic into a function
getResolvedValue()
, which is called in one place:getStylesDeclarations()
Testing Instructions
There should be no regressions in the way "ref" or relative path resolution takes place in the editor.
To test, create a theme.json file with some ref pointers and a relative path background image. Here are some examples:
Example block.html
Example theme.json
Then check the post and site editors.
Can you:
Also, run the tests!