-
-
Notifications
You must be signed in to change notification settings - Fork 68
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
Nested file resolution with design-tokens #1293
Comments
Hi @osiler, We follow the draft spec for design tokens : https://github.com/design-tokens/community-group This specification doesn't have a way of referencing other files inside a design tokens file. You have to include all token files from inside your CSS file. |
Hi, thanks for pointing that out. I think the area of the spec I am referring to is here but I don't see where this specifies that aliases must be limited to within one file. |
Maybe I misunderstood :) (keep in mind that I don't know SvelteKit and that I don't know anything about what you are trying to do :) ) |
Lets remove the svelte part for now, here is a minimal example. E.g input.css @design-tokens url('test_base.json') format('style-dictionary3');
/* Alias defined in brand, that links to test_base.json */
/* Uncomment this to demonstrate failed alias */
/* @design-tokens url('test_brand.json') format('style-dictionary3'); */
@custom-media --laptop (width >1200px) and (width <=1600px);
/* Base case, no aliasing */
@media (--laptop) {
main {
background: design-token('color.base.red.50');
}
}
/*Aliasing as test_brand.json has a token definition in test_base.json*/
/* Uncomment this to demonstrate failed alias */
/* @media (--laptop) { */
/* main { */
/* background: design-token('color.brand.primary.base'); */
/* } */
/* } */ test_base.json {
"color": {
"base": {
"red": {
"50": {
"value": "#FFE5EE",
"attributes": {
"font": "base"
}
}
}
}
}
} test_brand.json {
"color": {
"brand": {
"primary": {
"base": {
"value": "{color.base.red.50.value}"
}
}
}
}
} |
This comment was marked as resolved.
This comment was marked as resolved.
I better understand what is going on now. You have a case where you want to import multiple token files first and then resolve aliases after all tokens have been merged. But our plugin does the opposite. It is actually this issue : design-tokens/community-group#123 Changing this would be a breaking change, so we are not going to do that. When the designs tokens community group specifies how this should work we will add support for that behavior in this plugin. Up until then we are trying not to make any unexpected changes. |
@romainmenke thanks for the follow up. |
You can comment on the design tokens community group issue that you also depend on some behavior and explain your use case. That will help to inform the spec editors better. I am going to close this for now, thank you again for reporting. |
What would you want to propose?
I have been getting a SvelteKit based toolchain working with PostCSS and design tokens (inspired by the style-dictionary complete template). While everything is happy when using a flat file structure without nested token references, working with the complete example fails as I don't believe the
@design-tokens
can reference other Jsons. I understand that the design systems workflow is still relatively early, so thankyou for the plugin development.Suggested solution
You could collapse down the files in a directory and produce a large design-token Json file.
Additional context
No response
Validations
Would you like to open a PR for this feature?
The text was updated successfully, but these errors were encountered: