Skip to content

Support CSS light-dark() generation #581

@gossi

Description

@gossi

Summary

When tokens are turned into CSS for light and dark color scheme, this is usually done with a media query and a lot of code duplication.

Luckily CSS has a light-dark() function, that can be used for that. In order to generate such code, you need access to both the light and dark value of a token at the same time.

My first question isn't about Terrazzo generating the code, but having the dataset to do so (directly or per plugin). Since DTCG spec is 1.0 it has support for modes but - as much as I understood it - a token never has access to multiple mode values at the same time (I'm happy to be wrong here)? Is there spec work needed or is the modes spec sufficient enough?

Proposal & prior art

I've done this as a plugin for style dictionary myself as part of Theemo and used a different way of storing these permutations of value on a token (I refer to them as constrained token/value):

If spec work is needed, which surely is lower-level than modes, I think I researched the prior art myself.

Also I know timing wise the industry is implementing the stable token spec at first. We had a lovely session about this, now I remembered to put it into an issue :)

Extra

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions