-
Notifications
You must be signed in to change notification settings - Fork 567
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
Custom value transforms skip values with aliases #451
Comments
I came here to report this too—I was trying to do the same as #452 (piece together a token from an opaque color and an alpha value), but found that if I pulled the rgb from the opaque token via aliases, the color transforms weren't being applied. After logging all the transforms and scratching my head, it seems that aliased values just aren't transformed, even though they match the |
This is "working as expected" right now, but something we plan to fix in the next major version. Right now the "build" happens in a few distinct steps. The relevant steps to this are: transforming the tokens and then resolving aliases/references which are done in 2 passes of the entire style dictionary object as seen in this build diagram. Notably the transform step skips doing any value transforms on values that reference other values. Here is the line of code that does that: https://github.com/amzn/style-dictionary/blob/main/lib/transform/property.js#L36 The original intent was that the aliased token should already be properly transformed for the given format. Doing it this way does make it impossible to do certain things like output a variable reference in an output file, |
Cool. For now since we're just doing web, I can use my workaround and I'll eagerly await v3 😎 Thanks @dbanksdesign ! |
I'm still using |
+1. @dbanksdesign thanks for explanation. It would be really handy to transform resolved value. So I'm looking forward to this feature. |
This should work with the coming release of Style Dictionary 3.0. I will leave the issue open until the release occurs, but wanted to give you all a heads up that a solution was merged into the codebase with #371 |
For those curious and want to get access to this right now, you can install the upcoming release of style dictionary with the Here is an example using transitive transforms in the next version of Style Dictionary: https://github.com/amzn/style-dictionary/tree/3.0/examples/advanced/transitive-transforms And this documentation page has a more detailed explanation of upcoming changes in 3.0: https://amzn.github.io/style-dictionary/#/version_3 |
This is now released as part of 3.0 via #636 |
Is it possible to improve the conversion of json tokens using primitive math? thus I take this code and use it in Figma Token and it works Figma Token uses its own script to transform the value into a valid number. So, is it possible to do this? |
Edit: I was mistaken, it is working with |
Existing related issues
Maybe #208, although that seems like a larger architectural discussion.
Environment
style-dictionary --version
2.10.1
node -v
v12.16.1
npm -v
6.13.4
Test case
Given the following config.js:
And the following tokens.json:
Actual behavior
I see the following output:
Note how only the MATCHING lines are logged…
Expected behavior
I expect to see the following:
Note how both MATCHING and TRANSFORMING lines are logged…
Changing the
registerTransform
option fromtype: 'value'
totype: 'name'
ortype: 'attribute'
gives the expected behavior.Is this intended?
The text was updated successfully, but these errors were encountered: