@beydesign/tokens
v0.0.12
Published
BeyDesign System Tokens - CSS variables generated from Figma design tokens
Readme
Design Token Automation
This repository manages the automated workflow for transforming Figma design tokens into platform-specific formats (CSS) for our design system.
Overview
This project automates the process of:
- Receiving design tokens from Figma (via Tokens Studio for Figma)
- Resolving token references and relationships
- Transforming tokens into CSS variables
- Publishing the processed tokens as an npm package
Installation
npm install @beydesign/tokensUsage
// Import CSS variables in your project
import '@beydesign/tokens/build/css/variables.css';Or in CSS:
@import '@beydesign/tokens/build/css/variables.css';Workflow
graph LR
A[Figma] -->|Tokens Studio Plugin| B[tokens.json]
B -->|GitHub Action| C[resolve-tokens.js]
C -->|Transform| D[resolved-tokens.json]
D -->|Style Dictionary| E[CSS Variables]- Designers update tokens in Figma using Tokens Studio plugin
- Tokens Studio pushes updates to
tokens.json - GitHub Action automatically:
- Resolves token references
- Transforms tokens into CSS variables
- Commits the generated files
Generated Files
/tokens/resolved-tokens.json: Processed tokens with resolved references/build/css/variables.css: CSS custom properties ready for consumption
Development
Prerequisites
- Node.js 18 or higher
- npm
Setup
- Clone the repository:
git clone [repository-url]
cd [repository-name]- Install dependencies:
npm installLocal Development
To transform tokens locally:
# Transform tokens and resolve references
node scripts/resolve-tokens.js
# Generate CSS variables
node build.jsGitHub Actions
The repository includes an automated workflow (.github/workflows/transform-tokens.yml) that:
- Triggers on pushes to the main branch
- Processes the tokens
- Commits the generated files back to the repository
Contributing
- Ensure you have Tokens Studio for Figma set up with the correct GitHub integration
- Make token changes in Figma
- Push changes using Tokens Studio
- The automation will handle the rest!
Architecture
scripts/resolve-tokens.js: Resolves token references and relationshipsbuild.js: Transforms tokens into CSS using Style Dictionary- GitHub Actions workflow: Orchestrates the automated process
Releases
The project automatically:
- Versions the package (patch version for each token update)
- Creates a GitHub release
- Publishes to npm
Each release contains:
- Updated design tokens from Figma
- Generated CSS variables
- Full token reference documentation
NPM Package Structure
@beydesign/tokens/
├── build/
│ └── css/
│ └── variables.css # Generated CSS variables
└── tokens/
└── resolved-tokens.json # Processed design tokens