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

color.js transform mix #494

Open
andij opened this issue Mar 24, 2023 · 0 comments
Open

color.js transform mix #494

andij opened this issue Mar 24, 2023 · 0 comments

Comments

@andij
Copy link
Contributor

andij commented Mar 24, 2023

Is your feature request related to a problem? Please describe.

I'd like to use the mix function within chroma.js to transform colours.

Describe the solution you'd like

The capability of using design tokens to modify a colour with the mix function, described here: https://gka.github.io/chroma.js/#chroma-mix

Resulting in a token setup like this:

"error": {
  "value": "{ theme.color.error.value }",
  "modify": [
   {
     "type": "mix",
     "color": "white",
     "ratio": 0.9,
     "mode": "lrgb"
    }
  ]
}

Describe alternatives you've considered

Using the brighten function results in undesirable colours.

Currently the mix function works (with limitations), as the default ratio of 0.5 and the default mode of lrgb is being applied with this token setup:

"error": {
  "value": "{ theme.color.error.value }",
  "modify": [
   {
     "type": "mix",
     "amount": "white"
    }
  ]
}

It is currently possible to use alpha to achieve the correct outcome, but it relies on the background of the containing element to be white, which is not 100% predictable.

"error": {
  "value": "{ theme.color.error.value }",
  "modify": [
    {
      "type": "alpha",
      "amount": 0.05
    }
  ]
}
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

1 participant