-
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: keep core and theme preset variables and classes even if they are overwritten #27082
Conversation
Size Change: +173 B (0%) Total Size: 1.2 MB
ℹ️ View Unchanged
|
Squashed commits: [0ef9982] Global Styles: Keep core and theme preset classes and variables even if they are overwritten.
a763bd4
to
a2040a3
Compare
👋 I've been looking at the current state of how user-provided colors work and this PR. What if we made this work this way:
What do you think? I'm not convinced allowing users to remove theme colors is a good thing. It sets false expectations that we can't really control (that color is not used) and comes with some conceptual&implementation complexity I don't think we need at the moment. |
@@ -177,7 +177,7 @@ class WP_Theme_JSON { | |||
*/ | |||
const PRESETS_METADATA = array( | |||
array( | |||
'path' => array( 'settings', 'color', 'palette' ), |
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 think we already discussed this? I may be dreaming, though 😅 so I'm going to list why I don't think this is a good idea:
- it forces all the code that processes the presets to hold a partial reference to its path (
settings
), which they shouldn't need to. - we can't automate updating the docs from this info without also holding a reference to
settings
- a reader of the code can't know where these are sourced from without looking at how they're processed
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.
Hi @nosolosw,
I applied this change here because as part of this PR I needed to retrieve and set presets from deactivatedSettings instead of from settings.
gutenberg_experimental_set(
$this->contexts[ $context ]['deactivatedSettings'],
$preset['path'],
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.
With the caveat that I'm not sure this should work this way, as I mentioned below, I also wanted to share that perhaps is a way to balance both needs?
Depends on: #27077
This PR makes sure core and global styles preset variables and classes are kept even if they are overwritten.
Users may change or delete the presets, and the UI (e.g: color palette) should reflect that. But if the theme is using the preset variable in other place we should not break the theme and should still have the variable present. This PR makes sure the variables and classes are always present.
How has this been tested?
I added the 2021 blocks theme.
I deleted the preset background color.
I verified the background color was still applied,