Style Dictionary Setup Complete
Successfully integrated Style Dictionary 5.1.1 into the CloudAlt monorepo as a centralized design token management system.
What Was Accomplished
Section titled βWhat Was Accomplishedββ Package Structure Created
Section titled ββ Package Structure Createdβpackages/design-tokens/βββ tokens/ # Source token JSON files (3-tier hierarchy)β βββ global/ # Global tokens (all apps)β β βββ semantic-colors.json # Success, warning, error, info + ecosystem colorsβ β βββ animation.json # Transitions, durations, easingβ βββ divisions/ # Division-level tokens (shared within division)β β βββ stay-overnight/β β β βββ spacing.jsonβ β β βββ typography.jsonβ β β βββ shadows.jsonβ β β βββ layout.jsonβ β βββ stay-match/β β βββ roommate/β β βββ altfinder/β β βββ bonjour-services/β β βββ pride-city/β βββ apps/ # App-level tokens (unique to each app)β βββ stay-overnight/β β βββ hostguest-web.jsonβ β βββ pinkguest-web.jsonβ β βββ orangeguest-web.jsonβ β βββ purpleguest-web.jsonβ βββ stay-match/β β βββ staymatch-web.jsonβ βββ roommate/β β βββ roommate-guru-web.jsonβ βββ altfinder/β β βββ altfinder-web.jsonβ βββ bonjour-services/β βββ bonjour-services-web.jsonβββ build/ # Generated platform outputs (git-committed)β βββ css/ # CSS custom propertiesβ βββ scss/ # SCSS variablesβ βββ js/ # JavaScript/TypeScriptβ βββ tailwind/ # Tailwind config formatβ βββ react-native/ # React Native TypeScriptβ βββ json/ # JSON for documentationβββ style-dictionary.config.js # Build configurationβββ package.json # Package manifest with scriptsβββ project.json # Nx configurationβββ README.md # Comprehensive documentationβββ .gitignore # Excludes node_modulesβ Token Categories Migrated
Section titled ββ Token Categories Migratedβ3-Tier Hierarchical System:
-
Global Tokens (
tokens/global/)- Semantic colors (success, warning, error, info)
- Ecosystem colors (pink, orange, purple, green, plum-wine, travelers-teal, hopper-lime)
- Animation tokens (durations, easing, transitions)
-
Division Tokens (
tokens/divisions/{division}/)- Spacing scale (shared across all apps in division)
- Typography (fonts, sizes, weights, line heights)
- Shadows (elevation levels)
- Layout (max widths, containers, border radius)
-
App Tokens (
tokens/apps/{division}/{app}.json)- Unique color palettes per app
- App metadata (name, description)
- Optional semantic color overrides
β Build Outputs Generated
Section titled ββ Build Outputs GeneratedβStyle Dictionary successfully generates:
| Platform | File | Format | Use Case |
|---|---|---|---|
| CSS | build/css/variables.css | CSS custom properties | Web stylesheets |
| SCSS | build/scss/_variables.scss | SCSS variables | SASS/SCSS projects |
| JavaScript | build/js/tokens.js | ES6 module | React, Vue, vanilla JS |
| TypeScript | build/js/tokens.d.ts | Type declarations | TypeScript projects |
| Tailwind | build/tailwind/tokens.js | Module format | Tailwind config |
| React Native | build/react-native/tokens.ts | TypeScript | React Native apps |
| JSON | build/json/tokens.json | Nested structure | Documentation |
| JSON | build/json/tokens-flat.json | Flat structure | Inspection |
β Nx Integration
Section titled ββ Nx Integrationβ- Project:
design-tokensconfigured in Nx graph - Build Command:
yarn nx run design-tokens:build - Watch Mode:
yarn nx run design-tokens:build:watch - Clean:
yarn nx run design-tokens:clean - Lint:
yarn nx run design-tokens:lint
β Documentation Created
Section titled ββ Documentation Createdβ- README.md: Comprehensive guide with usage examples, workflows, and integration instructions
- Inline Comments: All token files have descriptive comments
- Type Safety: TypeScript declarations for IDE autocomplete
Usage Examples
Section titled βUsage ExamplesβWeb (CSS Variables)
Section titled βWeb (CSS Variables)β@import '@cloudalt-frontend/design-tokens/css';
.button { background-color: var(--semantic-success); padding: var(--spacing-4) var(--spacing-6); border-radius: var(--layout-border-radius-md); transition: all var(--transition-duration-DEFAULT) var(--transition-timing-ease);}
/* App-specific colors */.pinkguest-button { background-color: var(--app-pinkguest-web-colors-primary); color: var(--app-pinkguest-web-colors-accent);}Tailwind Configuration
Section titled βTailwind Configurationβimport tokens from '@cloudalt-frontend/design-tokens/tailwind';
export default { theme: { extend: tokens, },};React/TypeScript
Section titled βReact/TypeScriptβimport tokens from '@cloudalt-frontend/design-tokens';
const Button = () => ( <button style={{ backgroundColor: tokens.semantic.success, padding: `${tokens.spacing[4]} ${tokens.spacing[6]}`, borderRadius: tokens.layout.borderRadius.md, }} > Click me </button>);
// Using app-specific tokensconst PinkGuestButton = () => ( <button style={{ backgroundColor: tokens.app['pinkguest-web'].colors.primary, color: tokens.app['pinkguest-web'].colors.accent, }} > Pink Guest </button>);React Native
Section titled βReact Nativeβimport tokens from '@cloudalt-frontend/design-tokens/react-native';import { StyleSheet } from 'react-native';
const styles = StyleSheet.create({ button: { backgroundColor: tokens.semantic.success, padding: tokens.spacing[4], borderRadius: tokens.layout.borderRadius.md, }, // App-specific styling pinkGuestButton: { backgroundColor: tokens.app['pinkguest-web'].colors.primary, },});Build Process
Section titled βBuild ProcessβManual Build
Section titled βManual Buildβ# Build onceyarn nx run design-tokens:build
# Watch mode (rebuild on changes)yarn nx run design-tokens:build:watch
# Clean generated filesyarn nx run design-tokens:cleanAutomatic Build
Section titled βAutomatic BuildβAdd to CI/CD pipeline:
- name: Build Design Tokens run: yarn nx run design-tokens:buildIntegration Points
Section titled βIntegration Pointsβ1. Existing Theme Package
Section titled β1. Existing Theme PackageβBefore (packages/theme/src/tokens.ts):
- Manual TypeScript object
- Hard-coded values
- No platform variants
After (with design-tokens):
import tokens from '@cloudalt-frontend/design-tokens';
export const colors = { primary: { 50: tokens.ColorPrimary50, 100: tokens.ColorPrimary100, // ... etc }};2. Tailwind Preset
Section titled β2. Tailwind PresetβBefore (packages/config/tailwind-preset.js):
- Manually maintained theme object
After:
import tokens from '@cloudalt-frontend/design-tokens/tailwind';
export default { theme: { extend: tokens, },};3. Storybook Documentation
Section titled β3. Storybook DocumentationβIntegration:
import tokens from '@cloudalt-frontend/design-tokens';
// Use tokens to display current design systemexport const BrandColors = () => ( <ColorSwatch name="Primary 500" color={tokens.ColorPrimary500} />);4. React Native Apps
Section titled β4. React Native AppsβAll 40+ mobile apps can now import tokens:
import tokens from '@cloudalt-frontend/design-tokens/react-native';
export const theme = { colors: { primary: tokens.ColorPrimary500, secondary: tokens.ColorSecondary500, },};Benefits Achieved
Section titled βBenefits Achievedββ Single Source of Truth
Section titled ββ Single Source of Truthβ- Before: Tokens duplicated in theme package, Tailwind config, mobile styles
- After: Defined once in JSON, generated for all platforms
β Type Safety
Section titled ββ Type Safetyβ- Auto-generated TypeScript declarations
- IDE autocomplete for all tokens
- Compile-time error checking
β Platform Consistency
Section titled ββ Platform Consistencyβ- Same color values across web, mobile, iOS (future), Android (future)
- Guaranteed visual consistency
β Easy Updates
Section titled ββ Easy Updatesβ- Change token value once
- Rebuild generates all platform files
- Commit both source and generated files
β Scalability
Section titled ββ Scalabilityβ- Add new platforms (iOS Swift, Android XML) without changing source
- Support multiple brands with token overrides
- Dark mode variants easily managed
Workflow
Section titled βWorkflowβgraph TD A[Edit tokens/*.json] --> B[Run nx run design-tokens:build] B --> C{Generate Outputs} C --> D[CSS Variables] C --> E[Tailwind Config] C --> F[React Native TS] C --> G[TypeScript/JS] D --> H[Web Apps] E --> H F --> I[Mobile Apps] G --> H G --> INext Steps
Section titled βNext StepsβImmediate Tasks
Section titled βImmediate Tasksβ-
Migrate Existing Usage
- Update
packages/themeto import from design-tokens - Update
packages/config/tailwind-preset.jsto use generated tokens - Update Storybook stories to import from design-tokens
- Update mobile apps to use React Native tokens
- Update
-
Add to Build Pipeline
- Add
design-tokens:buildto pre-commit hook - Add to CI/CD pipeline (GitHub Actions)
- Add to Nx affected commands
- Add
-
Documentation
- Add design token guide to main README
- Create examples for each platform
- Document brand-specific overrides
Future Enhancements
Section titled βFuture Enhancementsβ-
Brand Variants
tokens/βββ core/ # Shared base tokensβββ altfinder/ # altFinder brand overridesβββ roommate/ # roommate brand overridesβββ homestay/ # homestay brand overrides -
Figma Integration
- Install Tokens Studio plugin
- Sync design tokens from Figma
- Automate design β code workflow
-
iOS/Android Support
platforms: {ios: {transformGroup: 'ios-swift',buildPath: 'build/ios/',files: [{destination: 'StyleDictionaryColor.swift',format: 'ios-swift/class.swift',}],},android: {transformGroup: 'android',buildPath: 'build/android/',files: [{destination: 'colors.xml',format: 'android/resources',}],},} -
Dark Mode
- Create
tokens/themes/dark.jsonwith overrides - Generate separate CSS files for dark mode
- Use CSS custom properties for theme switching
- Create
-
Semantic Aliases
{"color": {"button": {"primary": { "value": "{color.primary.500}" }}}}
Commands Reference
Section titled βCommands Referenceβ# Build tokensyarn nx run design-tokens:buildyarn nx build design-tokens
# Watch modeyarn nx run design-tokens:build:watch
# Clean generated filesyarn nx run design-tokens:clean
# Run from package directorycd packages/design-tokensyarn buildyarn build:watchyarn clean
# Check Nx graphyarn nx graph
# See affected projectsyarn nx affected:graphFile Structure Summary
Section titled βFile Structure Summaryβpackages/design-tokens/βββ tokens/ # SOURCE FILES (edit these)β βββ color.json # π¨ Color paletteβ βββ typography.json # π Typography systemβ βββ layout.json # π Spacing, borders, shadowsβ βββ animation.json # β‘ Breakpoints, transitionsββββ build/ # GENERATED FILES (don't edit)β βββ css/variables.css # Web CSS variablesβ βββ scss/_variables.scss # SCSS variablesβ βββ js/tokens.js # JavaScript ES6β βββ js/tokens.d.ts # TypeScript declarationsβ βββ tailwind/tokens.js # Tailwind configβ βββ react-native/tokens.ts # React Nativeβ βββ json/tokens.json # Documentationββββ style-dictionary.config.js # Build configurationβββ package.json # Package manifestβββ project.json # Nx configurationβββ README.md # Documentationβββ .gitignore # Excludes build/Success Metrics
Section titled βSuccess Metricsβ- β Style Dictionary 5.1.1 installed and configured
- β 4 token categories migrated from TypeScript to JSON
- β 8 platform outputs generated successfully
- β Type-safe TypeScript declarations
- β Nx integrated with build, watch, and clean targets
- β Documented with comprehensive README and examples
- β Ready for production use across 40+ apps
Troubleshooting
Section titled βTroubleshootingβBuild fails with import error
Section titled βBuild fails with import errorβ- Ensure youβre using
importsyntax in config (ESM) - Check Node version (requires Node 18+)
Tokens not updating
Section titled βTokens not updatingβ- Run
yarn nx run design-tokens:build - Check that source JSON files are valid
- Clear build directory:
yarn nx run design-tokens:clean
Type errors in IDE
Section titled βType errors in IDEβ- Restart TypeScript server
- Run build to regenerate
.d.tsfiles - Check that package.json
typesfield is correct
Resources
Section titled βResourcesβConclusion
Section titled βConclusionβStyle Dictionary is now fully integrated into the CloudAlt monorepo, providing:
- Centralized token management - Single source of truth
- Multi-platform support - Web, mobile, and future platforms
- Type safety - Auto-generated TypeScript declarations
- Scalability - Ready for 40+ apps and multiple brands
- Developer experience - Simple build commands, hot reload
The foundation is set for a production-ready design system that scales across the entire monorepo! π