tokens-studio / figma-plugin

Official repository of the plugin 'Tokens Studio for Figma' (Figma Tokens)
https://www.figma.com/community/plugin/843461159747178978
MIT License
1.32k stars 190 forks source link

2.0: Fix variable references when references aren't coming from any active themes #2911

Closed six7 closed 1 week ago

six7 commented 1 week ago

Closes https://github.com/tokens-studio/figma-plugin/issues/2906

When we're creating variables, we currently use themes that are active to inform what variables should be used as references. However, if those theme groups aren't active, we won't know what variable references to use for tokens and will fall back to raw hex values inside variables. Especially in multi-file setup users sometimes only enable one theme group, meaning they won't have the necessary references available.

What does this pull request do?

Changes the logic to add another set of themes to the merge function, so that the references from the current theme group have preference, but after that we'll take into account other themes.

Note that this is kind of flawed as we will pick the first available variable reference that we find. However, I'd say it's OK enough, given:

Before:

CleanShot 2024-06-24 at 08 32 53@2x

After:

CleanShot 2024-06-24 at 08 32 33@2x

Testing this change

With this change, the references correctly map. Before, they used hex values.

changeset-bot[bot] commented 1 week ago

⚠️ No Changeset found

Latest commit: e6bc8134a58a6aaf128f32ab26a8450534626a3a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR