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

Fix bug where aliases to remote variables could not be updated when syncing tokens to Figma #23

Merged
merged 2 commits into from
Mar 19, 2024

Conversation

james04321
Copy link
Collaborator

@james04321 james04321 commented Mar 18, 2024

For the sync_tokens_to_figma.ts script, if a tokens file has aliases to variables in remote collections, e.g. "$value": "{name_of_variable}", update those alias references when needed. This issue was brought up in #20.

The previous behavior was that if a tokens file has aliases to variables in a remote collection, those aliases would cause a 400 response from the POST /v1/files/:file_key/variables endpoint, as the script was sending up invalid variable ids inside the alias objects.

Now, the script will match up token values with remote variable names and update aliases when needed.

Note: we are limited by the variables API in that we cannot alias variables that aren't already consumed by current file.

Demo:

Here is a demo of the sync_tokens_to_figma.ts script updating a Figma file that has a Semantic variables collection with aliases to variables published from another file.

Screen.Recording.2024-03-18.at.8.13.33.AM.mov

Test Plan

  • In one file, create and publish a variable collection
  • In another file, create a variable collection with variables that alias to variables from the file above
  • Run npm run sync-figma-to-tokens to export the variables from the second file into a tokens file
  • Run npm run sync-tokens-to-figma on the exported tokens file to sync the tokens back to Figma. The result is that we should noop instead of getting a 400 error from the REST API.

@james04321 james04321 marked this pull request as ready for review March 18, 2024 14:03
@elainefigma
Copy link

The changes and tests make sense to me!

@james04321 james04321 merged commit 281d7fb into main Mar 19, 2024
1 check passed
@james04321 james04321 deleted the james-yang/fix-remote-aliases branch March 19, 2024 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants