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

It's true trying to introduce logic is a slippery slope. But similar to
themes we can have 'flags' which can change values by their presence, and
said flags can be flipped by much more complex conditional logic outside of
the tokens file.

On Tue, 13 Sep, 2022, 1:04 pm Romain Menke, ***@***.***>
wrote:

> 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
>
> @design-tokens url('./tokens-light.json') ***@***.*** 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.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/design-tokens/community-group/issues/169#issuecomment-1245015596>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AEKS36BLHIKZIP5QQ66LBJ3V6AU6PANCNFSM6AAAAAAQLEF4XA>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>


-- 
GitHub Notification of comment by nesquarx
Please view or discuss this issue at https://github.com/design-tokens/community-group/issues/169#issuecomment-1246008670 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 22:23:21 UTC