Skip to content

Commit 080d3be

Browse files
adbergenCopilot
andauthored
DC-36(feat): Design Token System with USWDS Integration (#3)
* feat: added token design implementation leveraging vite and uswds design system * chore: ignore claude init file * feat: implemented pnpm workspace to run entire application with simple commands * feat: designs for multiple states supported * chore: cross-compatibility using condition check based on OS Co-authored-by: Copilot <[email protected]> * chore: updated design token management adr * chore: consolidated scripts and lifted pnpm-lock.yaml * chore: removed public ignore since moving away from gulp * feat: optimize USWDS bundle size from 17.7MB to 656KB by selective asset copying --------- Co-authored-by: Copilot <[email protected]>
1 parent e847115 commit 080d3be

22 files changed

+3885
-24
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,3 +419,6 @@ FodyWeavers.xsd
419419
*.msix
420420
*.msm
421421
*.msp
422+
423+
# AI
424+
CLAUDE.md
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# 3. Design token management with Figma Tokens Studio and Vite
2+
3+
Date: 2025-11-19
4+
5+
## Status
6+
7+
Accepted
8+
9+
## Context
10+
11+
The Summer EBT Self-Service Portal needs to support customization for 50+ states while
12+
maintaining a consistent design system foundation. Each state requires its own visual identity
13+
(colors, typography, spacing) while adhering to USWDS (U.S. Web Design System) standards and
14+
federal accessibility requirements.
15+
16+
Key requirements:
17+
- **Multi-state branding**: Each state needs customizable theme tokens (DC, CA, TX, etc.)
18+
- **Designer-developer workflow**: Designers work in Figma, developers need automated sync
19+
- **USWDS compliance**: Must integrate with USWDS theming system
20+
- **Scalability**: Clear workflow that scales across 50+ state implementations
21+
22+
Without automated token management, each state implementation would require manual
23+
translation of design decisions into code, creating maintenance burden and design-code drift.
24+
25+
## Decision
26+
27+
We will use **Figma Tokens Studio** for token management with a **Vite-based custom USWDS compiler**.
28+
29+
**Core Architecture**:
30+
- **Token Source**: Figma Tokens Studio plugin with GitHub sync to `design/states/{state}.json`
31+
- **Token Organization**: One JSON file per state following W3C Design Tokens specification
32+
- **Transformation**: Node.js scripts convert tokens to USWDS SCSS variables and inject fonts
33+
- **Compilation**: Vite compiles USWDS with state-specific theme tokens using modern build tooling
34+
- **Optimization**: Lightning CSS, sass-embedded, PurgeCSS for production bundle optimization
35+
36+
**Workflow**: `Figma → Tokens Studio → GitHub → JSON → Transformation Scripts → SCSS → Vite → CSS Bundle`
37+
38+
## Alternatives Considered
39+
40+
### Alternative 1: @uswds/compile (Official Gulp-based tooling)
41+
**Why rejected**: Gulp is a legacy build tool with slower build times. USWDS documentation
42+
explicitly supports custom compilers. Vite unifies our toolchain and provides modern
43+
performance optimizations while maintaining full USWDS compatibility.
44+
45+
### Alternative 2: Style Dictionary
46+
**Why rejected**: Requires manual Figma export workflow (no GitHub sync). For our web-only
47+
use case, the platform-agnostic capabilities add complexity without benefit. Figma Tokens
48+
Studio's direct GitHub integration eliminates manual export steps.
49+
50+
### Alternative 3: CSS Custom Properties at Runtime
51+
**Why rejected**: USWDS requires IE11 support, which lacks CSS custom property support.
52+
Build-time compilation is more performant and aligns with USWDS architecture.
53+
54+
### Alternative 4: Manual SCSS Variables
55+
**Why rejected**: Does not scale to 50+ state implementations. Manual synchronization is
56+
error-prone and creates a bottleneck in the design-development workflow. Automated pipeline
57+
is essential for maintaining consistency and velocity.
58+
59+
## Consequences
60+
61+
### Positive
62+
- **Single source of truth**: Figma becomes the authoritative source for all design tokens
63+
- **Automated workflow**: Design changes sync to code automatically via GitHub
64+
- **USWDS compatibility**: Full compliance with USWDS theming and browser requirements
65+
- **Scalable to 50+ states**: Same pattern replicable across all state implementations
66+
- **Modern developer experience**: Vite with HMR for rapid iteration
67+
- **Production optimization**: Automated bundle optimization with Lightning CSS and PurgeCSS
68+
69+
### Negative
70+
- **Custom tooling maintenance**: Token transformation scripts require ongoing maintenance
71+
- **Third-party dependency**: Reliance on Figma Tokens Studio plugin
72+
- **Learning curve**: Team must understand token transformation and Vite configuration
73+
74+
### Risks and Mitigation
75+
**Risk**: Figma Tokens Studio plugin abandonment
76+
**Mitigation**: JSON format is portable; migration path to Style Dictionary exists
77+
78+
**Risk**: USWDS version changes breaking compatibility
79+
**Mitigation**: Custom compiler follows official USWDS patterns documented by USWDS team
80+
81+
**Risk**: State-specific token conflicts
82+
**Mitigation**: Clear naming conventions and USWDS namespace prevent collisions
83+
84+
## References
85+
86+
**Implementation Details**: See `docs/design-token-system.md` for technical specifications,
87+
performance metrics, and implementation guide.
88+
89+
**Key Documentation**:
90+
- [USWDS Custom Compiler Guide](https://designsystem.digital.gov/documentation/getting-started/developers/phase-two-compile/)
91+
- [Figma Tokens Studio Documentation](https://docs.tokens.studio/)
92+
93+
## Related ADRs
94+
- **ADR 0002**: Adopt Clean Architecture
95+
96+
## Notes
97+
This ADR documents the production-ready implementation for DC as the first state. The pattern
98+
will be replicated for all subsequent state implementations (CA, TX, FL, etc.).

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "sebt-portal",
3+
"version": "1.0.0",
4+
"private": true,
5+
"description": "Summer EBT (SUN Bucks) Self-Service Portal - Root package for convenience scripts",
6+
"scripts": {
7+
"web:dev": "pnpm --filter @sebt/web dev",
8+
"web:build": "pnpm --filter @sebt/web build",
9+
"web:build:dc": "pnpm --filter @sebt/web build:dc",
10+
"web:build:co": "pnpm --filter @sebt/web build:co",
11+
"web:tokens": "pnpm --filter @sebt/web tokens",
12+
"web:tokens:dc": "pnpm --filter @sebt/web tokens:dc",
13+
"web:tokens:co": "pnpm --filter @sebt/web tokens:co",
14+
"web:preview": "pnpm --filter @sebt/web preview",
15+
"api:run": "dotnet watch --project src/SEBT.Portal.Api",
16+
"api:build": "dotnet build",
17+
"api:test": "dotnet test",
18+
"api:restore": "dotnet restore",
19+
"dev": "concurrently -n \"API,Web\" -c \"blue,green\" \"pnpm api:run\" \"pnpm web:dev\"",
20+
"dev:web-only": "pnpm web:dev",
21+
"install:web": "pnpm --filter @sebt/web install",
22+
"install:all": "pnpm install"
23+
},
24+
"devDependencies": {
25+
"concurrently": "^9.2.1"
26+
},
27+
"engines": {
28+
"node": ">=18.0.0",
29+
"pnpm": ">=8.0.0"
30+
}
31+
}

0 commit comments

Comments
 (0)