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

Add support for relative colors #636

Open
uhafner opened this issue Feb 26, 2025 · 3 comments
Open

Add support for relative colors #636

uhafner opened this issue Feb 26, 2025 · 3 comments

Comments

@uhafner
Copy link

uhafner commented Feb 26, 2025

In the Jenkins project we are using oklch colors. In order to use such colors in Echarts I wanted to use your library to convert these oklch colors to rgb colors (see jenkinsci/echarts-api-plugin#383). This works quite well for absolute colors like oklch(60% 0.2601 12.28), but for relative colors like oklch(from oklch(55% 0.2308 256.91deg) 2% 0.075 h) the call new Color(color).to("sRGB").toString({format: "hex"}); fails with an exception.

Is there a plan to support such relative colors as well?

@LeaVerou
Copy link
Member

Hi there @uhafner!
This is definitely in scope, though no idea when we might get to it.
Meanwhile, as a workaround, you can use the color to set the color on a dummy element and then read back the computed style.

@facelessuser
Copy link
Collaborator

I'm curious on exactly how much 'relative' stuff Color.js plans to support. Does it plan on implementing its own support and logic for things like calc()? Or does it plan to keep relative support fairly simple?

@LeaVerou
Copy link
Member

I'm curious on exactly how much 'relative' stuff Color.js plans to support. Does it plan on implementing its own support and logic for things like calc()? Or does it plan to keep relative support fairly simple?

That’s the million dollar question 😁 I don't have an answer right now. It's unclear how much utility that provides without variables, and the implementation effort involved is pretty significant. I'd be inclined to support this as a plugin, rather than part of core Color.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants