-
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
ColorPalette: Update label correctly when value is CSS variable #41461
Conversation
Size Change: +23 B (0%) Total Size: 1.24 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.
LGTM 🚀
- ✅ Code changes look good
- ✅ New Storybook example works as expected
- ✅ Original issue in the block editor is fixed
- ✅ Thank you for going the extra mile and adding unit tests 👏
Thanks for fixing the issue! theme.json used for the test{
"version": 2,
"settings": {
"layout": {
"contentSize": "650px",
"wideSize": "1000px"
},
"color": {
"palette": [
{
"slug": "orange",
"color": "orange",
"name": "Orange"
},
{
"slug": "wp-preset-color",
"color": "var(--wp--preset--color--pale-pink)",
"name": "Preset Color"
},
{
"slug": "wp-preset-gradient",
"color": "var(--wp--preset--gradient--vivid-cyan-blue-to-vivid-purple)",
"name": "Preset Gradient"
},
{
"slug": "rgb",
"color": "rgb(34, 12, 64)",
"name": "RGB"
},
{
"slug": "rgba",
"color": "rgba(34, 12, 64, 0.6)",
"name": "RGBA"
},
{
"slug": "hsl",
"color": "hsl(30, 100%, 50%)",
"name": "HSL"
},
{
"slug": "hsla",
"color": "hsla(30, 100%, 50%, 0.6)",
"name": "HSLA"
},
{
"slug": "long-label-color",
"color": "#ff0000",
"name": "Long Long Long Long Long Long Label"
}
]
}
}
} fixcolor-palette-var.mp4Personally, I was concerned about the following two points, but I think they are out of the scope of this PR.
|
@t-hamano Sounds good, thank you. As for the latter point, I do think the uppercase is more consistent, but no strong opinion. Feel free to propose it if you like, and one of the designers can take a look! |
* ColorPalette: Update label correctly when value is CSS variable * Add unit tests * Add story * Add changelog
I'm still seeing this issue. Is the fix released? |
If you're using the Gutenberg plugin, yes. Otherwise, I believe not. It will be released in WordPress 6.1. |
Fixes #41157
What?
Fixes a bug where the color name label would not update correctly when switching between colors that were CSS variables.
Why?
The
colord( value ).toHex()
normalization that we were doing before finding a color match does not work for CSS variables, returning the fallback result of#000000
. Because all CSS variables got normalized down to#000000
, we could not reliably find the current color in the list of colors.How?
If a color value looks like a CSS variable, don't try to normalize it to a hex value.
Testing Instructions
npm run storybook:dev
Known issue with text label contrast switching: #41459