Skip to content
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: Contrast checking doesn't work with CSS variables #41459

Closed
mirka opened this issue May 31, 2022 · 0 comments · Fixed by #47373
Closed

ColorPalette: Contrast checking doesn't work with CSS variables #41459

mirka opened this issue May 31, 2022 · 0 comments · Fixed by #47373
Assignees
Labels
[Package] Components /packages/components

Comments

@mirka
Copy link
Member

mirka commented May 31, 2022

The ColorPalette component uses the contrast() function of the colord library to decide whether to render the text label of the color in black or white.

This does not work when the color value is a CSS variable. We'd probably need to do something like getComputedStyle( bgElement ).getPropertyValue( '--my-color' ) to get the actual color value to pass to colord.

Screenshot

Text label is rendered in white on a yellow background

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Components /packages/components
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants