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
|
andrewserong
left a comment
There was a problem hiding this comment.
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! 🚀
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
{ "$schema": "../../schemas/json/theme.json", "version": 3, "settings": { "appearanceTools": true }, "styles": { "color": { "text": "Salmon", "background": "DodgerBlue" }, "blocks": { "core/verse": { "color": { "text": { "ref": "styles.color.background" }, "background": { "ref": "styles.color.text" } } }, "core/quote": { "color": { "text": { "ref": "styles.color.text" } }, "background": { "backgroundImage": { "url": "file:./img/1024x768_emptytheme_test_image.jpg" } }, "dimensions": { "minHeight": "100px" } } } } }Then check the post and site editors.
Can you:
Also, run the tests!