Comments (3)
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. dark.json
and light.json
with the same token (but different values) inside, e.g. tokens.bg
(no mode reference.)
from design-tokens.
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.
from design-tokens.
To be clear we are on the same page here let's compere JSON structure we've got.
Based on today's results from figma using Design Tokens plugin.
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 dark
mode.
"primitives": {
"light": {
"white-01": {
"type": "color",
"value": "#ffffffff",
"blendMode": "normal"
}
},
"dark": {
"white-01": {
"type": "color",
"value": "#000000ff",
"blendMode": "normal"
}
}
},
"tokens": {
"header-bg": {
"type": "color",
"value": "{primitives.dark.white-01}"
}
}
}
It might look broken since there is no easy way to get primitives.light.white-01
. The fact that only last one of used aliases are considered seems to be not that obvious.
And now the questions:
- Based on given results, can you please confirm if the result is correct (mainly
primitives.dark.white-01
) ? - Is this plugin supposed to work only for single modes?
- @lukasoppermann you've mentioned creating two files for each mode separately. Is there (or will be) a possibility to choose which mode should be used while exporting?
from design-tokens.
Related Issues (20)
- Bug with Variables export HOT 2
- Variable aliases do not take into account token prefix settings HOT 1
- Double neasted mode name in json output
- Variable modes are not added if the collection name is uppercase in figma.
- Aliases to aliases cause wrong category to be set
- Plugin not working HOT 5
- Send design tokens to URL option does not work : Error 422
- Variables export not working. HOT 7
- Reference tokens not correct HOT 11
- Gradient angle not correct HOT 1
- Cannnot send design token to github HOT 5
- Tokens as a source for truth rather than figma? HOT 1
- Content-Security-Policy is blocking our company url HOT 1
- prefix exclusions should work with variables too, not just styles HOT 1
- Font weights are not extracted from custom font HOT 1
- Feature Request: Push File To Gitlab
- Mode name are duplicated in referenced values HOT 22
- Last component of variable names are always exported in lowercased
- Question of your point of view about design tokens JSON as source of truth HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from design-tokens.