-
-
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
json output: missing modes in referenced tokens #285
Comments
Hey @rganko happy to accept a PR to deal with spaces. But I think it should be already working the way it does now, or do you experience a bug? For the modes, the way you suggest is pretty uncommon. What we currently do is also not great. The best option would be to export one file per mode, but I am not sure if this is technically possible. Mode should not be in the token name at all, as this breaks a lot of the magic of tokens, but for this we need multiple files e.g. |
I'd love to better understand why one particular mode is included in the referenced name rather that removing it entirely. For a user with multiple modes for component tokens, won't there only ever be one mode with correct references? While the rest would always be wrong? I'm running into something very similar to the problem mentioned above, except my primitive and component token collections both have a matching set of modes and there's still only one mode ever included in the referenced primitive names. I was also was hoping for the proposed output @rganko provided, but removing the mode from the name entirely seems like it would be almost equally helpful. Is the current functionality, where 'mode 2' (whichever Figma mode is listed last) is included in referenced token names regardless of their mode, the intended functionality for the foreseeable future? (Assuming there aren't significant changes made in how Figma does things.) I'm fine writing some extra code to work around some of this, I was assuming I'd have to be using the JSON structure to make some of this work (top level as collections, second level as modes) - but also having to strip out one particular mode name from all referenced primitives feels awfully bad to me. I'm trying to figure out if my structure is fundamentally incompatible with this plugin and standard use cases, or if we're just in a temporary weird spot because variables are relatively new and things are likely to keep changing. |
To be clear we are on the same page here let's compere JSON structure we've got. Note: For single mode every thing works great (thank you for your work). In case of having another mode (light, dark), json structure seams to consider only last one from all of the modes that are available. See json below - token's path only considers
It might look broken since there is no easy way to get And now the questions:
|
@rganko I am not sure if you wrote the code above as an example only, but if it is not I feel like you can solve your problem by restructuring your Figma variable setup. After this you can create a different collection, there you can add as many modes as you like and use the variables you defined in the primitives collection to set up the different modes. This should solve your problem, plus, allow you to use better semantical variable names (in your example, "dark" mode has a variable called "white-01" which is set to the opposite of white!). so you'll get to have something like: {
"primitives": {
"colors": {
"white": "#fff",
"black": "#000"
}
},
"colors": {
"light": {
"primary": {
"type": "color",
"value": "{primitives.color.light}"
},
"secondary": {
"type": "color",
"value": "{primitives.color.dark}"
}
},
"dark": {
"primary": {
"type": "color",
"value": "{primitives.color.black}"
},
"secondary": {
"type": "color",
"value": "{primitives.color.light}"
}
}
},
"tokens": {
"light": {
"header-bg": {
"type": "color",
"value": "{primitives.primary}"
}
},
"dark": {
"header-bg": {
"type": "color",
"value": "{primitives.secondary}"
}
}
}
} |
Having two modes for
primitives
collection ("Mode 1", "Mode 2"), I can see only one of defined modes for other collection, that uses primitives as reference.Current exported json output:
The text was updated successfully, but these errors were encountered: