-
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
Custom colors are lost when styles are changed #48407
Comments
I think this is the intended behavior. Step 1 Step 2 Step 3 Your confusion, rightly, arise from lack of this explanation in the UI. For sure there are opportunities for improvement. This is final user territory, potential not developer, so a better explanation is mandatory. Imagine that an user create 10 color and then change style just because he likes the fonts. Potential solution: 1 2 3 |
@tresorama, thank you for the extensive explanation, but it seems to me that this is a bug, because the colors are lost even when previewing other styles. Look please: anonymous_33050487-8578-47f9-a8ef-28cbe5579485_video.mp4Shouldn't it work the way that it saves its custom colors for each style? |
Unfortunately, at the moment it saves its custom color for each "theme". At the moment, you cannot save "custom things" for each style, but for each theme only. Consider this:
But if :
"Styles" are like children of the theme, meaning that every theme can have its own "styles", and each "style" is bounded to its theme. Styles are not cross-theme.
|
Anyway @mgawe you raised a great issue, because this behavior is not ideal in current stage. I'm not an expert in Gutenberg and i have used it only for 2 weeks so maybe some other folk can describe an ideal use case for a not developer. |
@tresorama, I use custom colors to define the color palette for a dark mode theme, so I wouldn't want to give up on that. |
Can you explain how your dark mode system work? |
Sure! This is a very simple solution.
|
Note about following exampleThe following example ....
ExampleMaybe you can define"slot", "light" and "dark" colors inside // in theme.json
{
"settings": {
"colors" : {
"palette": [
{
"slug": "primary",
"name": "primary",
"color": "var(--wp--preset--color--light-primary)"
},
{
"slug": "light-primary",
"name": "light-primary",
"color": "#fff"
},
{
"slug": "dark-primary",
"name": "dark-primary",
"color": "#111"
},
and then control the swap in your css file /* in your-css-file.css */
@media (prefers-color-scheme:dark) {
body {
--wp--preset--color--primary: var(--wp--preset--color--dark-primary);
}
} or if you can handle the "writing" you can also opt out a css file and use // in theme.json
{
"styles": {
"css": "@media (prefers-color-scheme:dark) { body { --wp--preset--color--primary: var(--wp--preset--color--dark-primary);}}",
} |
Thanks a lot, but management has to be from the Site Editor (it's not for me, but my clients). |
You can teach them to not touch "slot" colors in Editor, and to customize "dark" and "light" variant only. |
@kathrynwp Is there any chance to give it a higher priority? This is clearly a bug. Thanks! |
Related |
I agree this is the intended style, as @tresorama says. #50102 is going to introduce site-wide global styles so that settings like custom color palettes can be reused in different themes and variations. |
I would also be happy if the issue is fixed. I have just addressed the issue in the Slack channel #fse-outreach-experiment with a corresponding video. |
This is relevant to this other issue: Additional CSS Erased When Switching Style Variations in WordPress 6.2 |
Having looked into this while exploring a possible fix for #50685 the only way I can see to fix this in general for all global style customisations to variations is to add a new global styles CPT for each variation. Currently, if you select a new theme a global styles entity is added for that theme, and all style customisations for that theme are saved to it. This is why you can make global styles changes to a theme, switch to another theme and make changes, then switch back to your first theme and the original changes are still there. With a variation it just replaces all of the user customisations in the theme global style entity with the styles from the variation, as @tresorama noted above. It has to do this as it wouldn't be possible to effectively merge all the differences, as there is currently no way to tell which are user style customisations, and which are the variation customisations. Even if you did merge them, once you saved it and then switched to another variation you would end up stacking variation styles on top of variation styles. One alternative would be to treat a variation switch the same as a theme switch so a new global styles entity is created, enabling you to move between variations without losing customisations to each. You wouldn't see customisations to one variation in another, but at least you wouldn't lose them when switching back and forth. But, this would need some way of identifying which theme+variation global styles entity should be used. That is my reading of it anyway. I may be overlooking a reason why variations couldn't operate the same as themes in this regard. I will add a new enhancement issue outlining what would be needed to make this change. |
There is some background here about the rationale for the current setup. Based on this it won't be as simple as adding a new global styles entity for each variation save as suggested above. Some thinking will need to be done about the wider user/variation/theme setup and the impact of any change on themes/plugins, etc. Some other related issues:
Given the number of existing issues around this topic I won't make another one - but it might be useful to pick one of the existing ones that best reflects the issue and close all the others in favour of that one. |
Maybe having a situation with these layers:
Could let "deep merging" ... And also migrate user style to an other theme ... |
Closing this out in favor of #45371 Like Glen, I agree we have a number of duplicate issues that risk slowing down rather than speeding up this effort. |
Description
Hi, I noticed a problem with custom color palette in the site editor (as the title).
Step-by-step reproduction instructions
Screenshots, screen recording, code snippet
screen-capture.1.webm
Environment info
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
The text was updated successfully, but these errors were encountered: