-
-
Notifications
You must be signed in to change notification settings - Fork 190
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reference doesn't exist: global.spacing.sm.value tries to reference spacing.xs, which is not defined #691
Comments
Think of token sets as files in style dictionary. The filename is never part of the token name. To use it correctly with style dictionary, in your JSON the "global" should not be there, instead the filename would be "global". To export all token sets you'd need to split the output object into multiple files. We'll introduce a way to export to multiple files to make that a seamless experience. |
Hi @six7, First of all, thank you for all the good work you put into this Plugin. This is pushing forward the community building and thinking Design Systems worldwide! Now, allow me to re-open this thread as I am falling into this problem myself. If I follow your recommendation I can't make the Style Dictionary build to work because my Token Key names does not include the file name or Token Set name. The problem is that the way Tokens are referenced between Token Sets in the Figma plugin is not reflected after the Tokens are exported. At export, we have to manage the Token Set level that is not reflected in the name of Token Reference in the Plugin (either as the file name if we export Token Sets individually or as the Token Set levels in the JSON file if we export All Token Sets at once). Let me explain below: ExplanationsHere is an example if you want to reproduce the situation. In the Figma Tokens Plugin, my Tokens are organized around 2 Token Sets:
As described in your Token Set documentation, this allows us to "semantically separate tokens". A Core Token could be for example: {
"core": {
"color": {
"white": {
"value": "#ffffff"
}
}
}
} A Public Token that references this Core Token could be for example: {
"public": {
"color": {
"primary": {
"value": "{color.white}"
}
}
}
} To use this token as a reference for a Public Token in the Figma Plugin I would use {color.white} but the path to this value in Style Dictionary would be ExamplesStyle Dictionary using the All Token Sets exportThe exported file looks like this: // tokens.json
{
"core": {
"color": {
"white": {
"value": "#ffffff"
}
}
}
"public": {
"color": {
"primary": {
"value": "{color.white}"
}
}
}
} Result: Style Dictionary can't find Style Dictionary exporting Token Sets as individual files// core.json (using the Token Set name as the filename and excluding it at the JSON level like you recommend)
{
"color": {
"white": {
"value": "#ffffff"
}
}
} // public.json (using the Token Set name as the filename and excluding it at the JSON level like you recommend)
{
"color": {
"primary": {
"value": "{color.white}"
}
}
} Result: Style Dictionary can't find The only workaround I found is to:
This workaround prevents me from using the All Token Sets file (the file used as the single source of truth in sync with Github or JSONbin) because the reference path to the core Tokens would be {core.token-name} in place of {private.core.token-name}. In the All Token Sets export, the Token Set is automatically used as a level to structure the JSON but is not in the nomenclature used to reference tokens in the Figma Plugin. Look forward to having your opinion on that. Cheers! |
@apart-edgar you may want to read through the thread starting with this comment: #703 (comment) In short, your pipeline should be "export" -> |
Hi @jam-awake, Thank you for your quick reply and the solution! I've written my own documentation if this can help anyone in the future. https://github.com/apart-edgar/figma-tokens-with-style-dictionary |
Nice. |
Hmmm, interesting. Thank you for your feedback! I might be confronted with some difficulties soon too as I was only focusing on making a basic Style Dictionary build to work. I did not really start to use variables, build mixins or transform CSS property values yet. I'll update my documentation in case I run into some issues. |
Describe the bug
References are not resolved in style-dictionary, when using multiple token sets.
Maybe a duplicate of #480
To Reproduce
Steps to reproduce the behavior:
{spacing.xs}
Expected behavior
{global.spacing.xs}
)Screenshots or Screencasts
![Screenshot 2022-05-10 at 16 20 20](https://user-images.githubusercontent.com/1157777/167651661-13b159c6-c955-46cb-a14e-9fd64f27179d.png)
When using the full reference (including the token set name), the references are broken.
Example JSON export
The text was updated successfully, but these errors were encountered: