-
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
ColorPalette
: Color picker doesn't work correctly with variable colors
#46492
Comments
colord usage in https://github.com/WordPress/gutenberg/blob/trunk/packages/components/src/color-palette/index.tsx can be modified to check for variables. loose example:
this could very well be cleaned up. though isSelected logic would need to change: i'm not sure why value needs to be checked against colord and not just the color prop - but we pretty much use only css variables internally, and have a custom color palette picker to support them. |
@sergiu-radu Also, the actual color value pointed to by the CSS variable is output as some kind of CSS file or inline style, so it may be difficult to reference that value from the color picker component. I would be glad to know what exactly is your idea of CSS variable support, and what kind of solution you would like to see. |
@t-hamano yes, that's exactly right! The actual color value is output as an inline style to the
If this solution looks okay to you, we can go ahead with an actual PR that would potentially fix this. Otherwise, if you have better ideas, please share and we'll work towards the implementation :) |
@andreiglingeanu |
@ciampo @mirka Should we get the value of a CSS variable if it is output inline in |
ColorPalette
: Color picker doesn't work correctly with variable colors
Thank you for flagging! We're aware of the fact that By looking at the issue, it looks like it can be split into two sub-issues:
@mirka and I can look further into addressing point 1 (ie. from the |
If anyone would like to submit a PR for the first sub-issue, the (I hope this behavior is consistent across browsers 🤞) |
I'm trying this approach and I would like to submit a PR as it seems to work as expected 👍 |
Please do! You can ping @mirka and myself for the review, happy to help as always 🙏 |
Hello everyone 👋
If I set the value of a color in
theme.json
file to be a CSS custom property - the color picker is not showing the color correctly inside the color picker popover when you select a color from the theme color presets - it returns to#000000
.I am setting the theme palette colors in
theme.json
file like this because the theme has multiple color palettes and the user could change the palette from customizer.Here is a quick video that better explains the problem - https://d.pr/v/8tSl5E
The question is, if it is not possible to use variable colors inside color picker, could you please add support for this?
Thank you very much for your time!
The text was updated successfully, but these errors were encountered: