-
-
Notifications
You must be signed in to change notification settings - Fork 136
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
Mode name are duplicated in referenced values #308
Comments
I've got the same, I think I have the same issue. I cloned this repo, and ran a few older versions though, and it seems like something has maybe changed on Figma's side, since even the older versions seem broken. |
@MildTomato , I took a quick look at the MR tagged in my earlier message, and the changes there seem to be the cause of the issue. I haven't dug deeper yet but I don't think the issue lies with Figma. |
re the screenshot above @lukasoppermann It does work, but it removes the Figma Variable mode references, which we use 😅. |
Thanks for a speedy reply! I'll give it a try later today, if its all good on my side, I'll close this issue :) |
Ann darn, okay so you want it only in the json, but not in the variable name? I am not sure how the usage is, but we could add a checkbox to include it in the name. Would anyone be up to sending a PR for this? |
Yea, I think that's right. I'm going to test just editing the JSON first to make sure that actually does fix things. update - yep, that seems to be the fix. |
@lukasoppermann If I run edit - I can have a look and see if I can post a PR, if I can get my head around how all this works. |
@MildTomato that would be great. The settings file you need to add a checkbox to is GeneralSettings (after the highlighted code). You also need to add the option, I'd name it I think (but I am not sure), you'd afterwards just change this line to set addMode to |
@lukasoppermann nice one. well, that makes it easy 😄 |
I have made a fix here - I (almost) blindly followed the instruction from @lukasoppermann two answers above I hope this is good enough or at least a good base to solve the problem. |
I hope this gets fixed soon. It's quite annoying. |
This bug has corrupted my JSON file too, but the problem is more complex. I have '01 Primitives' collection, where I have 2 columns: 'light-mode' and 'dark-mode', sample variable: brand/500. Now, there are two issues. When creating a variable in '02 Aliases' e.g. "color.bg.brand.default",
Now the issue is, that even if my default collection (column) in '01 Primitives' is set in Figma to 'light-mode', in the JSON file it's referring by default to 'dark-mode' in both scenarios. If I turn the setting 'Reference mode in variables' off, which is also not a solution if you have more than 1 theme, it's still using the wrong, 'dark-mode' column for the source of HEX codes instead of 'light-mode'. I missed that issue previously, as my 'dark-mode' is WIP, it's just a duplicate of the 'light-mode' where I only edited grays to be more bluish. Hope it gets fixed soon, as my whole setup is broken now :-( It would be also nice to have a setting in the Plugin section which is the default collection e.g. 'light mode' or 'dark mode' from '01 Primitives'. |
Any chances for a quick fix? 🥲 |
@jacekpuzio-kk there is a PR open here with a possible fix and some discussion. |
@0m4r yeah, but i'm looking for a updated plugin as a designer so that I could use it in Figma 😅 |
I think it's a bigger issue in the JSON structure, as when it exports for example: Figma Variables1-Primitives
2-Semantics
3-Components
It becomes:
Issues
I'm not very familiar with JSON, and only started using Figma a month ago, so my understanding of Design Tokens comes from https://www.contentful.com/blog/design-token-system/ , which suggests a schema, where instead of the Variable Mode split taking place above the Variable Categories, i.e. (Collection.Mode.Category.Variable), Variables should have a Nested Object Property "ValuesByMode", with one reference for each Variable Mode, so perhaps:
Would JSON be able to refer to just {2-semantics.error.primary}? I'm not sure how this would build the stylesheet and how then that is used in a page that wants to toggle between modes and have the components react accordingly. Sorry for the long comment and naivety. |
the "mode" is an issue also when setting up a figma variable that references another one from the same mode, but this must be worked around by setting up a different figma variable structure as it is merely impossible to detect if a reference belongs to the same mode as the variable being parsed. @TylerCousins in your specific case, I would not set any mode in the primitives, as they are primitives, they should be intended to be used anywhere. {
"light": {
"error": {
"primary": {
"type": "color",
"value": "{1-primitives.reds.20}"
}
}
},
"dark": {
"error": {
"primary": {
"type": "color",
"value": "{1-primitives.reds.80}"
}
}
}
} |
@0m4r thanks for the reply, Typo on my part, edited to fix that. I currently avoid referencing from the same mode, but Figma enabling that means some might use it and yes, that would conflict. |
yeah, I can see that. I am not sure if there is any information on the same mode reference that Figma can provide. (I have got the same issue on the project I am working on, so, I feel you! - If you find a better solution do let me know :P) |
Could the whole "mode" feature be reverted and then reintroduced making sure that there's access to the old behavior? Our current flow has been broken for a few months because none of the options produces the previous result. This is quite unfortunate. |
@okaverin even older versions before the unfortunate update were incorrectly providing random HEX codes if you had more than 1 theme... i.e. your main theme is Light Mode, but in the JSON files tokens are referring to Dark Mode and using those HEX codes instead... |
So, I have just updated #309 with the possibility to configure to add a mode name to the token name, the token value, both or none of them. I'd be really happy if someone would try it out and give feedback. |
🥳 |
Hello,
Since the fix #300 , the name of the mode is now included in the
value
of the design token when exporting the Figma Variables. Is this a bug because the reference is now broken?Example:
The previous JSON export for
background/Primary Red/Default
would look like:However, it now exports with the additional
light
mode name invalue
We have a design token for a color (
color/lifeblood red/500
) that does not play a part of theming, but our library is now unable to reference it because it is now looking for the referencecolor/light/lifeblood red/500
).The text was updated successfully, but these errors were encountered: