Skip to content
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

Styles aren't Applied with Prefix Styles with Theme name #3145

Closed
keeganedwin opened this issue Sep 18, 2024 · 2 comments · Fixed by #3153
Closed

Styles aren't Applied with Prefix Styles with Theme name #3145

keeganedwin opened this issue Sep 18, 2024 · 2 comments · Fixed by #3153
Assignees
Labels
bug Something isn't working Figma non-local styles variables Publishing comp lib, styles and variables to consume Figma styles needs-responder

Comments

@keeganedwin
Copy link
Collaborator

keeganedwin commented Sep 18, 2024

Describe the bug
Currently when using non-local libraries for styles with the following setup and applying tokens in File 3, hex-values instead of styles are applied if and when the Global, Semantics and Themes (multiple themes) are selected. If I however deselect globals and semantics and ONLY have Themes selected, the plugin applies the style:

File 1: Export Global Styles

  • Push changes to the provider
  • Publish the library

File 2: Enable the global library

  • Export semantics
  • Push changes to the provider
  • Publish the library

File 3: Enable Global & Semantics

  • Export themes
  • Push changes to the provider
  • Publish the library

This bug is present in the library with the exported styles as well as an external library that has all three library enabled.

Insight from @six7 -

This seems to be related to the prefix styles with first part of token name setting. There were a few changes made to this recently which seems to be the cause of this error. We basically seem to only use the first active theme name to detect the name, which is wrong in this case.

Expected behavior
I think we should just go back to the previous functionality where regardless of how may themes are selected the plugin applies the styles of the Selected theme of each theme-group.

Screenshots or Screencasts
Recording

Figma file (optional)
I already have the files for this setup and can share the tokens if required.

@keeganedwin keeganedwin added bug Something isn't working Figma non-local styles variables Publishing comp lib, styles and variables to consume Figma styles needs-responder labels Sep 18, 2024
@six7 six7 changed the title Styles aren't Applied with Non-local Libraries Styles aren't Applied with Prefix Styles with Theme name Sep 19, 2024
@six7
Copy link
Collaborator

six7 commented Sep 19, 2024

Changed the title to reflect that this has nothing to do with non-local styles. This has to do with Prefix styles with theme name - if multiple themes exist we seem to always only use the first theme name due to https://github.com/tokens-studio/figma-plugin/blob/main/packages/tokens-studio-for-figma/src/plugin/TokenValueRetriever.ts#L22-L31 as well as

const stylePathPrefix = prefixStylesWithThemeName && activeThemes.length > 0 ? activeThemes[0].name : undefined;
where we seem to take the first theme name, which cannot work if you have multiple themes.

As part of this issue, please let's add some tests to verify the various behaviors

@keeganedwin
Copy link
Collaborator Author

Just adding that this is also present with exported typography styles in the same file. If I apply a typography token from the Bio/Light set it applies the style. As soon as I select Headless or Bio core it breaks and applies raw-values

CleanShot 2024-09-19 at 19 00 57@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Figma non-local styles variables Publishing comp lib, styles and variables to consume Figma styles needs-responder
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants