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

Modify tokens updater to support color aliases #226

Merged
merged 3 commits into from
Dec 2, 2024

Conversation

c4rlosviteri
Copy link
Contributor

Updates the token updater script to properly handle color aliases by implementing support for color references and options prefix management.

Main changes

  • Added detection for color tokens by checking $type property and parent type inheritance
  • Added support for color references and maintaining their structure
  • Added loading and tracking of options tokens for proper prefix management
  • Implemented reference normalization to handle options prefix based on token location

Technical details

  • Added isColorToken function to detect color tokens based on:

    • Direct $type: "color" declaration
    • Inheritance from parent type
  • Added normalizeReference function to:

    • Clean reference paths
    • Check if the reference points to an options token
    • Add/maintain the "options." prefix when needed
  • Added options token loading with:

    • Scanning of _options folder
    • Storage of valid color tokens
    • Path matching for nested tokens

Testing

The script has been tested with:

  • Direct color values
  • Color references
  • Nested color tokens
  • Options and non-options references

Example

From

{
  "color": {
    "icon": {
      "default": {
        "$value": "{color.warm-grey-600}",
        "$type": "color",
        "filePath": "tokens/global/color.json5"
      }
    }
  }
}

To

{
  "color": {
    "icon": {
      "default": {
        "$value": "{options.color.warm-grey-600}",
        "$type": "color",
        "docs": {}
      }
    }
  }
}

@c4rlosviteri c4rlosviteri force-pushed the pr/alias-tokens-updater branch from 4e1c88e to d9005e5 Compare November 26, 2024 03:54
@c4rlosviteri c4rlosviteri merged commit 38dd702 into next Dec 2, 2024
2 checks passed
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.

2 participants