-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
added better support for variable alias when transforming tokens using style dictionary #261
added better support for variable alias when transforming tokens using style dictionary #261
Conversation
…g style dictionary
Pull Request Test Coverage Report for Build 5956451766
💛 - Coveralls |
…iable-reference-values
…iable-reference-values
Hey, I think this is certainly one option, as I am also not sure exporting multiple files works. (Haven't had time to look into it). I would like this feature to be togglable via the UI. I guess we could tie this the If it is one, than it would reference modes in both the file structure on references, if it is off, it will be removed from both. WDYT? |
I think that makes sense since when mode reference is on and aliasing a variable with multiple modes does not work right now when transforming anyways. @lukasoppermann I believe I have updated the PR based on your feedback but if I did not understand it correctly, let me know. |
@lukasoppermann Is there anything else this PR needs? |
Hey @ryanzec there are some problems with this. It works fine when disabled, but when enabled it has a wrong setup in the file. I will investigate this further. Sorry for the long wait. |
Ahh, @ryanzec so the issue is, that you are replacing the reference and the variable name with the same mode. however the referenced variable is different and may come from a different mode and collection. |
Hey @ryanzec I had to rollback this PR. I didn't find the time to fix it and its blocking the merge of other changes. I tried to fix it in here: https://github.com/lukasoppermann/design-tokens/tree/fixForModesExport but did not succeed yet. Can you send a new PR with this and try to fix it. Use cases it needs to cover:
|
@lukasoppermann
|
@lukasoppermann Details I added the codes. |
* added better support for variable alias when transforming tokens using style dictionary (#261) * added proper support for variable alias when transforming tokens using style dictionary * process alias modes when modeReference is enabled * Update src/utilities/getVariables.ts * Update src/utilities/getVariables.ts --------- Co-authored-by: Lukas Oppermann <lukasoppermann@github.com> * add a button solely for saving the settings. * add functions auto-save of export settings * remove unnecessary code * change naming of button * reBuild the code --------- Co-authored-by: Ryan Zec <basire@gmail.com> Co-authored-by: Lukas Oppermann <lukasoppermann@github.com>
This makes changes so that the outputted design token can properly be transformed with style dictionary when using aliases for a variable value.
This PR adds in functionality so that after all variables are processed, it does a second pass on the variables and if the variable is an alias, it will basically create a copy of the variable and update both the
name
and thevalues
of the variable to account for the modes of the alias.Previous to these changes, this is an example of a alias variables design token output:
With the changes, the output is now:
Adding for the mode in the
values
is needed to make sure when transforming with style dictionary, the reference can be found. Adding the mode in thename
is needed to make sure there are not duplicate variables names.This seems like the cleanest way to add this functionality but let me know if there is any feedback.
This addresses #260