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

[css-color-5]: light-dark() doesn’t work with Relative Colors #10572

Closed
ai opened this issue Jul 13, 2024 · 2 comments
Closed

[css-color-5]: light-dark() doesn’t work with Relative Colors #10572

ai opened this issue Jul 13, 2024 · 2 comments
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-5 Color modification

Comments

@ai
Copy link

ai commented Jul 13, 2024

There is some compatibility issue between Relative Colors and light-dark() in all browsers:

.broken {
  --dynamic-bg: light-dark(oklch(70% 0 0), oklch(30% 0 0));
  background: oklch(from var(--dynamic-bg) l 0.05 160); /* browsers ignore it */
}

Maybe Relative Colors spec was created without thinking of light-dark()? But I think it really limits colors DX.

Demo: https://codepen.io/iskin/pen/yLWdxrR

@romainmenke
Copy link
Member

romainmenke commented Jul 13, 2024

This is not a spec issue.
Implementation haven't added support (yet).

This is the same underlying issue as lacking support for currentColor.

The relevant WPT tests can be found here : https://wpt.fyi/results/css/css-color/parsing/color-valid-relative-color.html?label=master&label=experimental&aligned&q=currentcolor

Each test with currentColor is failing in Chrome and Firefox, but Safari Preview just landed support.

In Safari Preview your demo also works as expected:

Screenshot 2024-07-13 at 12 55 02

@ai
Copy link
Author

ai commented Jul 13, 2024

Great, thanks for the explanation

@ai ai closed this as completed Jul 13, 2024
@svgeesus svgeesus changed the title [css-color-4]: light-dark() doesn’t work with Relative Colors [css-color-5]: light-dark() doesn’t work with Relative Colors Jul 14, 2024
@svgeesus svgeesus added Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. css-color-5 Color modification labels Jul 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closed as Question Answered Used when the issue is more of a question than a problem, and it's been answered. Commenter Satisfied Commenter has indicated satisfaction with the resolution / edits. css-color-5 Color modification
Projects
None yet
Development

No branches or pull requests

3 participants