Skip to content

Expand composite tokens into individual variables during export#3668

Draft
Copilot wants to merge 5 commits intomainfrom
copilot/fix-composite-tokens-export
Draft

Expand composite tokens into individual variables during export#3668
Copilot wants to merge 5 commits intomainfrom
copilot/fix-composite-tokens-export

Conversation

Copy link
Contributor

Copilot AI commented Oct 29, 2025

Composite tokens (typography, border, boxShadow, composition) were being filtered out during variable export because the system only recognized atomic token types.

Changes

  • New expansion utility (expandCompositeTokensForVariables): Breaks composite tokens into constituent properties before variable creation. Each property becomes an individually exportable variable with correct type mapping.

  • Integration point: Modified generateTokensToCreate to expand composites before filtering by tokenTypesToCreateVariable.

  • Type-safe mapping: Added explicit property-to-TokenType mapping to handle conversions from convertToDefaultProperty output to enum values (e.g., fontFamilyFONT_FAMILIES, borderWidthBORDER_WIDTH).

Example

A typography token:

{
  "heading.large": {
    "type": "typography",
    "value": {
      "fontFamily": "Inter",
      "fontSize": "24px",
      "fontWeight": "700"
    }
  }
}

Now exports as three separate variables:

  • heading.large.fontFamily (string)
  • heading.large.fontSize (number)
  • heading.large.fontWeight (number)

Border and boxShadow tokens expand similarly (e.g., border.color, shadow.blur).

Original prompt

This section details on the original issue you should resolve

<issue_title>Composite tokens are skipped during variable export</issue_title>
<issue_description>Describe the bug
Complex tokens (typography, border, shadows) are skipped during variable export
Note: This issue is reproducible with both exporting as themes and sets.
To Reproduce

  1. Create tokens with complex values:
    • Typography token with fontFamily, fontSize, lineHeight, etc.
    • Border token with multiple values
    • Box shadow token with multiple shadow properties
  2. Navigate to export functionality
  3. Select "Export as Variables" or a similar export option
  4. Attempt to export the token sets containing these complex tokens
  5. Review the exported output

Screenshots or Screencasts

https://github.com/user-attachments/assets/066bf68c-7341-42c1-8305-b9bbeded1bde
</issue_description>

Comments on the Issue (you are @copilot in this section)

@six7 @NuthanHyma what did you have in mind with `Expanded using the appropriate conversion utilities` ?

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@changeset-bot
Copy link

changeset-bot bot commented Oct 29, 2025

🦋 Changeset detected

Latest commit: d45a004

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tokens-studio/figma-plugin Patch

Not sure what this means? Click here to learn what changesets are.

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

Copilot AI and others added 4 commits October 29, 2025 16:28
- Created expandCompositeTokensForVariables utility to expand typography, border, boxShadow, and composition tokens into individual property tokens
- Integrated expansion into generateTokensToCreate to ensure composite tokens are expanded before filtering
- Added comprehensive tests for the expansion logic
- Added test case in updateVariables.test.ts to verify composite tokens are exported correctly

Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Fixed type assertion in expandCompositeTokensForVariables
- Added changeset for the fix
- Build and tests passing

Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Added explicit mapPropertyToTokenType function for safer type mapping
- Removed unsafe type assertions
- Added comprehensive property-to-type mapping
- All tests passing and build successful

Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
- Added comprehensive test for typography tokens with paragraph properties
- Verified that all TokenTypes enum values are correctly mapped
- All 7 tests passing

Co-authored-by: akshay-gupta7 <9948167+akshay-gupta7@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix skipping of composite tokens during variable export Expand composite tokens into individual variables during export Oct 29, 2025
Copilot AI requested a review from akshay-gupta7 October 29, 2025 16:49
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.

Composite tokens are skipped during variable export

2 participants