Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Style dictionary tokens#433

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
argyleink merged 9 commits intoargyleink:mainfromindaco:style-dictionary-tokens
Oct 24, 2023

Conversation

indaco
Copy link
Contributor

@indacoindaco commentedOct 23, 2023
edited
Loading

This PR implements thetoStyleDictionary script to generate a style dictionary compliant json file namedopen-props.style-dictionary-tokens.json

Related to#288

It is a first draft to check if the approach works for you. In case I can continue and finalising it. E.g.replace the reference to the CSS variables with the correct tokens (see below the sample for--radius-conditional)

The way I structured the tokens reflects the original naming convention.Here is the generated file for reference.

Below some examples:

colors

{"color": {"yellow": {"0": {"value":"#fff9db","type":"color"      },"1": {"value":"#fff3bf","type":"color"      },...}

borders

sizes
--border-size-{1-5}

turns into

"border": {"size": {"1": {"value":"1px","type":"border-width"      },"2": {"value":"2px","type":"border-width"      },...    }  }
radius
--radius-{1-6}--radius-conditional-{1-6}

turns into

{"radius": {"1": {"value":"2px","type":"border-radius"    },"2": {"value":"5px","type":"border-radius"    },...."conditional": {"1": {"value":"clamp(0px, calc(100vw - 100%) * 1e5, var(--radius-1))","type":"border-radius"        },"2": {"value":"clamp(0px, calc(100vw - 100%) * 1e5, var(--radius-2))","type":"border-radius"        },...    }  }}

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz CodeflowRun & review this pull request inStackBlitz Codeflow.

@indaco
Copy link
ContributorAuthor

Fixed the references to existing tokens so now

{"radius": {"1": {"value":"2px","type":"border-radius"    },"2": {"value":"5px","type":"border-radius"    },..."conditional": {"1": {"value":"clamp(0px, calc(100vw - 100%) * 1e5, {radius.1.value})","type":"border-radius"        },"2": {"value":"clamp(0px, calc(100vw - 100%) * 1e5, {radius.2.value})","type":"border-radius"        },...    }  }}

and

{"ease-squish": {"1": {"value":"{ease-elastic-in-out.1.value}","type":"other"      },"2": {"value":"{ease-elastic-in-out.2.value}","type":"other"      },...    },"ease-elastic": {"1": {"value":"{ease-elastic-out.1.value}","type":"other"      },...}

@argyleink
Copy link
Owner

nice, this looks good so far! what's left?
have you tested importing the generated JSON?

thanks for hackin on this 🙂

@indaco
Copy link
ContributorAuthor

indaco commentedOct 24, 2023
edited
Loading

I think I'm done!

The missing part was to structurenoise andnoise-filter as well asease and all its variants (avoiding excessive nesting).
Yes, I have run tests for the generated JSON in terms of values, references and correctness in my personal style dictionary project. Hope I did not miss anything.

Output

The updated output is availablehere for references.

Demo

Anyhow, ademo is available where I used@csstools/postcss-design-tokens as per in#288. Have a look to theapp.postcss file.

Notes

In a pure style dictionary project where using the generated tokens to build up your design system based on open-props, the basic config for style dictionary with css variables output only looks like the following

// config.js fileconstStyleDictionary=require('style-dictionary')StyleDictionary.extend({include:['./node_modules/open-props/open-props.style-dictionary-tokens.json'],source:['tokens/**/*.json'],platforms:{css:{// To preserve all the original values and units from the tokens, I am not using the predefined// transformGroup: `css` here but a list of transforms, because it includes the `size/rem`// transform clashing with values with units included into the definition.transforms:['attribute/cti','name/cti/kebab','time/seconds','content/icon','color/css'],buildPath:'dist/',files:[{destination:'variables.css',format:'css/variables',options:{outputReferences:true}}]}}}).buildAllPlatforms()

with some tokens like

{"color": {"border": {"default": {"value":"{color.gray.4.value}","type":"color",      },"primary": {"value":"{color.indigo.7.value}","type":"color",      }   }}

Copy link
Owner

@argyleinkargyleink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

rad, looks good, thanks for contributing!

power-rangers

indaco reacted with heart emoji
@argyleinkargyleink merged commit982f431 intoargyleink:mainOct 24, 2023
@indaco
Copy link
ContributorAuthor

Thanks for merging!!!

@indacoindaco mentioned this pull requestOct 24, 2023
@romainmenke
Copy link
Contributor

Thank you@indaco 🎉

indaco reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@argyleinkargyleinkargyleink approved these changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@indaco@argyleink@romainmenke

[8]ページ先頭

©2009-2025 Movatter.jp