argyleink / open-props

CSS custom properties to help accelerate adaptive and consistent design.
https://open-props.style
MIT License
4.78k stars 193 forks source link

A json source for style dictionary #288

Closed romainmenke closed 1 year ago

romainmenke commented 2 years ago

For postcss-design-tokens we currently have support for Style Dictionary as a source format.

(we would love to support the new format, but the latest draft has too many open issues)


I tried to use open props with the design-tokens.json exported file but the JSON is flattened and the token names have -- prefixes.

Screenshot 2022-09-22 at 11 00 03

In Style Dictionary format this could look like :

{
  "radius": {
    "1": {
      "value": "2px"
    },
    "2": {
      "value": "5px"
    },

This is not the output from using the Style Dictionary CLI to convert to CSS,SCSS,... It would be the Style Dictionary format itself.

@design-tokens url(node_modules://open-props/design-tokens) format('style-dictionary3');

.foo {
        /* works today: */
    color: design-token('--blue-1')
    /* would be nice to have: */
    color: design-token('blue.1')
}

related : https://github.com/tokencss/tokencss/issues/10#issuecomment-1251809298

I noticed that tokencss doesn't follow the new format (yet) and is closer to Style Dictionary. So this might be two fixes in one :)

argyleink commented 2 years ago

two in one sounds very nice! one of the reasons I dont ship Style Dictionary format is because there's so many props that wouldnt convert to other platforms. but maybe i could ship the props anyway and let folks use them for web and not cross platform?

regardless, it's a transform on the data and i've already got pipelines for exporting various formats. open props can def ship another format, especially if it'll dual resolve a couple use cases šŸ‘šŸ»

argyleink commented 1 year ago

fixed by #433