Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-seals-fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@tokens-studio/figma-plugin": patch
---

Fix bound variables being incorrectly mapped to base tokens when importing text styles
15 changes: 5 additions & 10 deletions packages/tokens-studio-for-figma/src/utils/findOrCreateToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ export function findOrCreateToken(
): StyleToCreateToken | undefined {
const boundVariables = style.boundVariables as Record<string, { id: string; } | undefined>;

// 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);
Expand Down Expand Up @@ -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
Expand Down
Loading