diff --git a/.changeset/poor-seals-fetch.md b/.changeset/poor-seals-fetch.md new file mode 100644 index 000000000..a09590370 --- /dev/null +++ b/.changeset/poor-seals-fetch.md @@ -0,0 +1,5 @@ +--- +"@tokens-studio/figma-plugin": patch +--- + +Fix bound variables being incorrectly mapped to base tokens when importing text styles diff --git a/packages/tokens-studio-for-figma/src/utils/findOrCreateToken.ts b/packages/tokens-studio-for-figma/src/utils/findOrCreateToken.ts index c25d90fe3..1454a0070 100644 --- a/packages/tokens-studio-for-figma/src/utils/findOrCreateToken.ts +++ b/packages/tokens-studio-for-figma/src/utils/findOrCreateToken.ts @@ -12,13 +12,6 @@ export function findOrCreateToken( ): StyleToCreateToken | undefined { const boundVariables = style.boundVariables as Record; - // Always check for existing token by value first (to preserve existing naming conventions) - const stringValue = String(value); - const existingTokenByValue = tokenArray.find((token) => String(token.value) === stringValue); - if (existingTokenByValue) { - return existingTokenByValue; - } - // Check for bound variables if (boundVariables?.[propertyKey]?.id) { const variable = localVariables.find((v) => v.id === boundVariables[propertyKey]?.id); @@ -48,9 +41,11 @@ export function findOrCreateToken( } // No bound variable or variable not found - look for existing token by value - const existingToken = tokenArray.find((token) => String(token.value) === stringValue); - if (existingToken) { - return existingToken; + // Always check for existing token by value first (to preserve existing naming conventions) + const stringValue = String(value); + const existingTokenByValue = tokenArray.find((token) => String(token.value) === stringValue); + if (existingTokenByValue) { + return existingTokenByValue; } // Create new token with default naming