tokens-bruecke / figma-plugin

TokensBrücke is a Figma plugin that converts Figma variables into design-tokens JSON.
MIT License
39 stars 7 forks source link

Alias resolution with Style Dictionary #4

Closed cailborg closed 9 months ago

cailborg commented 10 months ago

I've noticed your plugin adds the alias for a token as

"$value": "{base.primary.yellow}"

When you try to resolve aliases in style dictionary i'm getting a blank output file

Should the plugin output an alias path the same as the style dictionary example?

"$value": "{base.primary.yellow.value}"
PavelLaptev commented 10 months ago

Interesting. Thanks for feedback @cailborg I'll check it out. Which version of Style Dictionary do you use?

cailborg commented 10 months ago

Just latest at the moment, so 3.8.0

PavelLaptev commented 10 months ago

Thank, and for which platform, CSS? I'll check it in the morning 🙂

cailborg commented 10 months ago

Yep CSS and SCSS

PavelLaptev commented 10 months ago

Should work fine, without value at the end. I've checked a test JSON file with Style Dictionary playground — here is a link Looks like the reason in something else.


Also, I made Style Dictionary utils package. So, you can try to transform your tokens with it — https://github.com/tokens-bruecke/sd-utils

Here is a test repo with Github Actions — https://github.com/tokens-bruecke/tokens-deploy-with-actions

PavelLaptev commented 10 months ago

I made a custom build. In this build, the plugin will add .value at the end of the alias string. Can you check if it works for you?

plugin-test-2.zip

PavelLaptev commented 10 months ago

Also, might be the reason in this: "$value": "{base.primary.yellow.value}" that you're using DTCG format $value

PavelLaptev commented 10 months ago

Added value or $value (if it's the DTCG format) at the end of the alias paths.

dev-nicolaos commented 9 months ago

@PavelLaptev wouldn't it be more appropriate for this change to live in the style dictionary utils? The alias example provided by the spec does not append value to the end of an alias. Cobalt's (a DTCG parser) example matches the spec. Style dictionary is the only place I've seen so far where value is appended.

PavelLaptev commented 9 months ago

@dev-nicolaos thank you for your feedback. I think you're right. I'll leave adding value at the end of an alias optional.

PavelLaptev commented 9 months ago

@dev-nicolaos updated. It's now optional

image