Re: [community-group] Conditional token values (#169)

> To be honest, I do not think logic or conditions should exist in the spec. Design tokens are meant to contain raw values to be processed.

I actually agree and should have included this in my initial statement.
I think this is best solved by having multiple token files.

But if something like "theming" is handled by the spec I think it should be more abstract and include the cases listed above.

------

In our PostCSS plugin for style dictionary we solve this outside of token files : https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-design-tokens#is

```css
@design-tokens url('./tokens-light.json') format('style-dictionary3');
@design-tokens url('./tokens-dark.json') when('theme-blue') format('style-dictionary3');

.foo {
 color: design-token('color.background.primary');
}
```

The value of `color.background.primary` changes depending on user config when building the CSS.

The same mechanic can be expanded on later to include conditions typically found in `@media` or `@supports`.

-- 
GitHub Notification of comment by romainmenke
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/169#issuecomment-1245015596 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 13 September 2022 07:33:45 UTC