@discourser/design-system 0.22.2 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/figma-codex.json +2 -2
- package/docs/CSS_USAGE.md +235 -0
- package/docs/FIGMA_MAKE_SETUP.md +339 -0
- package/docs/GUIDELINES_REVIEW.md +728 -0
- package/docs/MAINTAINER_CHECKLIST.md +265 -0
- package/docs/TESTING_QUICK_REFERENCE.md +159 -0
- package/docs/TESTING_TOKENS.md +340 -0
- package/docs/active-stories/README.md +29 -0
- package/docs/active-stories/STORY-006a-figma-translation-foundations.md +324 -0
- package/docs/active-stories/STORY-006b-figma-translation-components.md +201 -0
- package/docs/active-stories/STORY-006c-figma-translation-layout-extension.md +258 -0
- package/docs/active-stories/STORY-008-kai-sidecar-fragments.md +137 -0
- package/docs/active-stories/STORY-011-verify-translation-docs.md +182 -0
- package/docs/archive/ARCHITECTURE-discourser-design-system.md +448 -0
- package/docs/claude-feed-back/ARCHITECTURE_DIAGRAM.md +243 -0
- package/docs/claude-feed-back/STYLING_VERIFICATION.md +89 -0
- package/docs/claude-feed-back/TEST_RESULTS.md +182 -0
- package/docs/context-share/ELEVATION_FIX_PLAN.md +903 -0
- package/docs/context-share/STORY-001-VALIDATION-PASSED.md +192 -0
- package/docs/context-share/STORY-002-IMPLEMENTATION-COMPLETE.md +161 -0
- package/docs/context-share/STORYBOOK_MCP_STRATEGY.md +867 -0
- package/docs/context-share/TESTING_GAPS_FILLED.md +353 -0
- package/docs/context-share/TOKEN_TESTING_SUMMARY.md +388 -0
- package/docs/context-share/code-connect-prompt.md +90 -0
- package/docs/context-share/dds-autonomous-pipeline.md +765 -0
- package/docs/context-share/fix-checkbox-radio-tokens.md +145 -0
- package/docs/context-share/icon-component-prompt.md +154 -0
- package/docs/context-share/icons/Audience.svg +3 -0
- package/docs/context-share/icons/AudioSpeaker.svg +3 -0
- package/docs/context-share/icons/BookmarkPlus.svg +3 -0
- package/docs/context-share/icons/ClipBoard.svg +8 -0
- package/docs/context-share/icons/DiscourserLogo.svg +4 -0
- package/docs/context-share/icons/ExitStudio.svg +4 -0
- package/docs/context-share/icons/Microphone.svg +5 -0
- package/docs/context-share/icons/NotebookPen.svg +3 -0
- package/docs/context-share/icons/PausePlay.svg +5 -0
- package/docs/context-share/icons/Play.svg +4 -0
- package/docs/context-share/icons/Record.svg +6 -0
- package/docs/context-share/icons/RepeatQuestion.svg +3 -0
- package/docs/context-share/icons/ScrollText.svg +3 -0
- package/docs/context-share/icons/Sparkles.svg +3 -0
- package/docs/context-share/icons/Speech.svg +3 -0
- package/docs/context-share/icons/StopPlay.svg +4 -0
- package/docs/context-share/icons/Timer.svg +3 -0
- package/docs/context-share/icons/UserProfile.svg +3 -0
- package/docs/context-share/m3-token-pipeline-audit.md +125 -0
- package/docs/context-share/storybook-mcp-kai-agent-revised-summary.md +211 -0
- package/docs/discourser-design-system-prd.md +3698 -0
- package/docs/figma-captures/01-typography.png +0 -0
- package/docs/figma-captures/02-button-iconbutton.png +0 -0
- package/docs/figma-captures/03-form-inputs.png +0 -0
- package/docs/figma-captures/04-form-controls.png +0 -0
- package/docs/figma-captures/05-data-display.png +0 -0
- package/docs/figma-captures/06-feedback.png +0 -0
- package/docs/figma-captures/07-overlays.png +0 -0
- package/docs/figma-captures/08-navigation-layout.png +0 -0
- package/docs/figma-captures/09-custom-components.png +0 -0
- package/docs/figma-captures/10-scenario-queue.png +0 -0
- package/docs/figma-captures/11-icon-library.png +0 -0
- package/docs/figma-make-docs/01-understanding-templates.md +235 -0
- package/docs/figma-make-docs/02-prerequisites.md +266 -0
- package/docs/figma-make-docs/03-creating-template.md +306 -0
- package/docs/figma-make-docs/04-adding-guidelines.md +448 -0
- package/docs/figma-make-docs/05-example-starter-code.md +590 -0
- package/docs/figma-make-docs/06-publishing-template.md +417 -0
- package/docs/figma-make-docs/07-maintenance.md +536 -0
- package/docs/figma-make-docs/08-faq.md +490 -0
- package/docs/figma-make-docs/README.md +95 -0
- package/docs/material-theme.json +418 -0
- package/docs/plans/2026-03-12-figma-token-export-rewrite.md +504 -0
- package/docs/plans/2026-03-12-step7-panda-token-resolution-design.md +119 -0
- package/docs/plans/2026-03-12-step7-panda-token-resolution.md +993 -0
- package/docs/token-name-mapping.json +850 -0
- package/docs/token-name-mapping.md +251 -0
- package/package.json +3 -2
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Token Testing Strategy
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document describes the comprehensive testing strategy for design tokens in the Discourser Design System. These tests prevent regressions in the three-layer token architecture.
|
|
6
|
+
|
|
7
|
+
## Test Categories
|
|
8
|
+
|
|
9
|
+
> **Total: 50 tests across 4 test files**
|
|
10
|
+
|
|
11
|
+
### 1. **Token Definition Tests** (`src/preset/__tests__/shadows.test.ts`) — 11 tests
|
|
12
|
+
|
|
13
|
+
**Purpose:** Verify semantic tokens are correctly defined and chained to base tokens.
|
|
14
|
+
|
|
15
|
+
**What it tests:**
|
|
16
|
+
- ✅ Semantic tokens (xs-2xl) reference correct base tokens (level1-5)
|
|
17
|
+
- ✅ Utility tokens (inset) remain independent
|
|
18
|
+
- ✅ No hardcoded Park UI values in semantic tokens
|
|
19
|
+
- ✅ All required tokens are present
|
|
20
|
+
- ✅ No unexpected tokens exist
|
|
21
|
+
|
|
22
|
+
**Example:**
|
|
23
|
+
```ts
|
|
24
|
+
it('sm should reference shadows.level2', () => {
|
|
25
|
+
expect(shadows.sm.value).toBe('{shadows.level2}');
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Catches:**
|
|
30
|
+
- Accidentally using hardcoded values instead of token references
|
|
31
|
+
- Missing token definitions
|
|
32
|
+
- Wrong token references (e.g., sm → level3 instead of level2)
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
### 2. **Recipe Token Usage Tests** (`src/preset/recipes/__tests__/recipe-shadows.test.ts`) — 16 tests
|
|
37
|
+
|
|
38
|
+
**Purpose:** Verify component recipes use semantic tokens (NOT base tokens).
|
|
39
|
+
|
|
40
|
+
**What it tests:**
|
|
41
|
+
- ✅ All shadow-using components use semantic tokens (xs-2xl)
|
|
42
|
+
- ✅ No recipe references base tokens (level0-5) directly
|
|
43
|
+
- ✅ STORY-003: Input/Textarea use focus-underline token
|
|
44
|
+
- ✅ STORY-003: RadioGroup uses inset-border token
|
|
45
|
+
- ✅ No inline var(--shadow-color) strings in recipes
|
|
46
|
+
- ✅ Custom shadows are documented and intentional
|
|
47
|
+
|
|
48
|
+
**Example:**
|
|
49
|
+
```ts
|
|
50
|
+
it('button recipe should use semantic tokens (xs, sm, md)', () => {
|
|
51
|
+
const elevated = button.variants?.variant?.elevated;
|
|
52
|
+
expect(elevated?.boxShadow).toBe('sm');
|
|
53
|
+
expect(elevated?._hover?.boxShadow).toBe('md');
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Catches:**
|
|
58
|
+
- Components bypassing semantic layer and using base tokens
|
|
59
|
+
- Regressions after refactoring
|
|
60
|
+
- Inconsistent token usage across components
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
### 3. **Transform Tests** (`src/languages/__tests__/transform.test.ts`) — 9 tests
|
|
65
|
+
|
|
66
|
+
**Purpose:** Verify design language contract is correctly transformed to Panda theme.
|
|
67
|
+
|
|
68
|
+
**What it tests:**
|
|
69
|
+
- ✅ Base tokens (level0-5) are created from elevation.levels
|
|
70
|
+
- ✅ M3 shadow values are preserved exactly
|
|
71
|
+
- ✅ Shadow values follow M3 pattern (two-part shadows)
|
|
72
|
+
- ✅ Elevation progression is correct
|
|
73
|
+
- ✅ Transform function doesn't mutate source data
|
|
74
|
+
|
|
75
|
+
**Example:**
|
|
76
|
+
```ts
|
|
77
|
+
it('should preserve M3 shadow values exactly', () => {
|
|
78
|
+
const expected = material3Language.elevation.levels;
|
|
79
|
+
expect(pandaTheme.tokens.shadows.level1.value).toBe(expected.level1);
|
|
80
|
+
});
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**Catches:**
|
|
84
|
+
- Lost or corrupted M3 elevation values during transform
|
|
85
|
+
- Incorrect token structure
|
|
86
|
+
- Mutations to design language contract
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### 4. **Integration Tests** (`src/preset/__tests__/token-resolution.test.ts`) — 14 tests
|
|
91
|
+
|
|
92
|
+
**Purpose:** Verify complete preset configuration has correct token architecture.
|
|
93
|
+
|
|
94
|
+
**What it tests:**
|
|
95
|
+
- ✅ Preset includes both base and semantic shadow tokens
|
|
96
|
+
- ✅ Semantic tokens reference existing base tokens
|
|
97
|
+
- ✅ No circular token references
|
|
98
|
+
- ✅ Inset token remains independent (STORY-002 requirement)
|
|
99
|
+
- ✅ Utility tokens (focus-underline, inset-border) are independent
|
|
100
|
+
- ✅ All recipes avoid base token usage (system-wide check)
|
|
101
|
+
- ✅ Utility tokens are used in appropriate recipes
|
|
102
|
+
- ✅ Token reference integrity across the system
|
|
103
|
+
|
|
104
|
+
**Example:**
|
|
105
|
+
```ts
|
|
106
|
+
it('semantic tokens should only reference existing base tokens', () => {
|
|
107
|
+
const baseTokenNames = Object.keys(baseShadows || {});
|
|
108
|
+
// Verify each semantic token reference is valid
|
|
109
|
+
expect(baseTokenNames).toContain(referencedToken);
|
|
110
|
+
});
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Catches:**
|
|
114
|
+
- Broken token references
|
|
115
|
+
- Missing base tokens
|
|
116
|
+
- Circular dependencies
|
|
117
|
+
- Integration issues between layers
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## Running Tests
|
|
122
|
+
|
|
123
|
+
### Run all token tests
|
|
124
|
+
```bash
|
|
125
|
+
pnpm test shadows
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Run specific test file
|
|
129
|
+
```bash
|
|
130
|
+
pnpm test shadows.test.ts
|
|
131
|
+
pnpm test recipe-shadows.test.ts
|
|
132
|
+
pnpm test transform.test.ts
|
|
133
|
+
pnpm test token-resolution.test.ts
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Run with coverage
|
|
137
|
+
```bash
|
|
138
|
+
pnpm test:coverage
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Watch mode during development
|
|
142
|
+
```bash
|
|
143
|
+
pnpm test --watch
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
---
|
|
147
|
+
|
|
148
|
+
## CI/CD Integration
|
|
149
|
+
|
|
150
|
+
### Pre-commit Hook
|
|
151
|
+
```bash
|
|
152
|
+
# .husky/pre-commit
|
|
153
|
+
pnpm test shadows --run
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### GitHub Actions
|
|
157
|
+
```yaml
|
|
158
|
+
- name: Test Token Architecture
|
|
159
|
+
run: pnpm test shadows --run
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Test Patterns
|
|
165
|
+
|
|
166
|
+
### Pattern 1: Token Reference Validation
|
|
167
|
+
```ts
|
|
168
|
+
// Verify semantic token references base token
|
|
169
|
+
expect(shadows.sm.value).toBe('{shadows.level2}');
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Pattern 2: Component Recipe Validation
|
|
173
|
+
```ts
|
|
174
|
+
// Verify recipe uses semantic tokens
|
|
175
|
+
expect(recipe.boxShadow).toMatch(/^(xs|sm|md|lg|xl|2xl)$/);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Pattern 3: Negative Testing (Anti-patterns)
|
|
179
|
+
```ts
|
|
180
|
+
// Verify no base tokens in recipes
|
|
181
|
+
expect(recipeString).not.toMatch(/['"]level[0-5]['"]/);
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Pattern 4: Structural Validation
|
|
185
|
+
```ts
|
|
186
|
+
// Verify token has expected structure
|
|
187
|
+
expect(token.value).toHaveProperty('base');
|
|
188
|
+
expect(token.value).toHaveProperty('_dark');
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Extending Tests for New Tokens
|
|
194
|
+
|
|
195
|
+
### Adding a new semantic shadow token
|
|
196
|
+
|
|
197
|
+
1. **Update `shadows.test.ts`:**
|
|
198
|
+
```ts
|
|
199
|
+
it('xxl should reference shadows.level5', () => {
|
|
200
|
+
expect(shadows.xxl.value).toBe('{shadows.level5}');
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
2. **Update coverage test:**
|
|
205
|
+
```ts
|
|
206
|
+
const requiredTokens = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', 'xxl', 'inset'];
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
### Adding a new component recipe
|
|
210
|
+
|
|
211
|
+
1. **Import the recipe:**
|
|
212
|
+
```ts
|
|
213
|
+
import { newComponent } from '../newComponent';
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
2. **Add recipe test:**
|
|
217
|
+
```ts
|
|
218
|
+
it('newComponent recipe should use semantic tokens', () => {
|
|
219
|
+
expect(newComponent.boxShadow).toMatch(/^(xs|sm|md|lg|xl|2xl)$/);
|
|
220
|
+
});
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
3. **Add to anti-pattern check:**
|
|
224
|
+
```ts
|
|
225
|
+
const recipes = { button, card, /* ... */, newComponent };
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
## Visual Regression Testing
|
|
231
|
+
|
|
232
|
+
While unit tests verify token definitions, visual regression tests verify the actual rendered output.
|
|
233
|
+
|
|
234
|
+
### Chromatic Integration (Recommended)
|
|
235
|
+
```bash
|
|
236
|
+
# Run visual regression tests
|
|
237
|
+
pnpm chromatic
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
### Manual Visual Testing
|
|
241
|
+
```bash
|
|
242
|
+
pnpm dev # Start Storybook
|
|
243
|
+
# Check each component in light + dark themes
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
**Components to visually verify:**
|
|
247
|
+
- Button (elevated variant)
|
|
248
|
+
- Card
|
|
249
|
+
- Dialog
|
|
250
|
+
- Drawer
|
|
251
|
+
- Popover
|
|
252
|
+
- Select
|
|
253
|
+
- Slider
|
|
254
|
+
- Switch
|
|
255
|
+
- Toast
|
|
256
|
+
- Tooltip
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Debugging Failed Tests
|
|
261
|
+
|
|
262
|
+
### Token reference mismatch
|
|
263
|
+
```
|
|
264
|
+
Expected: '{shadows.level2}'
|
|
265
|
+
Received: '{shadows.level3}'
|
|
266
|
+
```
|
|
267
|
+
**Fix:** Update semantic token definition in `src/preset/shadows.ts`
|
|
268
|
+
|
|
269
|
+
### Recipe using base token
|
|
270
|
+
```
|
|
271
|
+
Error: recipeString matches /level[0-5]/
|
|
272
|
+
```
|
|
273
|
+
**Fix:** Update recipe to use semantic token (xs, sm, md, lg, xl, 2xl)
|
|
274
|
+
|
|
275
|
+
### Missing base token
|
|
276
|
+
```
|
|
277
|
+
Error: baseTokenNames does not contain 'level6'
|
|
278
|
+
```
|
|
279
|
+
**Fix:** Either add the base token to material3.language.ts or fix the reference
|
|
280
|
+
|
|
281
|
+
### Transform not preserving values
|
|
282
|
+
```
|
|
283
|
+
Expected: "0px 1px 2px rgba(0,0,0,0.3)"
|
|
284
|
+
Received: undefined
|
|
285
|
+
```
|
|
286
|
+
**Fix:** Check transform.ts objectToTokens function and language contract
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Benefits of This Testing Strategy
|
|
291
|
+
|
|
292
|
+
### 1. **Prevents Regressions**
|
|
293
|
+
Tests catch when someone accidentally:
|
|
294
|
+
- Uses base tokens directly in components
|
|
295
|
+
- Breaks the token chain
|
|
296
|
+
- Removes required tokens
|
|
297
|
+
|
|
298
|
+
### 2. **Documents Architecture**
|
|
299
|
+
Tests serve as executable documentation showing:
|
|
300
|
+
- How tokens should be structured
|
|
301
|
+
- What the token chain looks like
|
|
302
|
+
- Which patterns are allowed/forbidden
|
|
303
|
+
|
|
304
|
+
### 3. **Enables Refactoring**
|
|
305
|
+
With comprehensive tests, you can:
|
|
306
|
+
- Safely refactor token definitions
|
|
307
|
+
- Swap design languages
|
|
308
|
+
- Update M3 values with confidence
|
|
309
|
+
|
|
310
|
+
### 4. **Fast Feedback**
|
|
311
|
+
Tests run in milliseconds:
|
|
312
|
+
- No need to rebuild Panda
|
|
313
|
+
- No need to check Storybook manually
|
|
314
|
+
- Instant feedback on token changes
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
## Best Practices
|
|
319
|
+
|
|
320
|
+
### ✅ DO:
|
|
321
|
+
- Run tests before committing
|
|
322
|
+
- Add tests for new tokens/recipes
|
|
323
|
+
- Keep tests focused and specific
|
|
324
|
+
- Use descriptive test names
|
|
325
|
+
- Test both positive and negative cases
|
|
326
|
+
|
|
327
|
+
### ❌ DON'T:
|
|
328
|
+
- Skip tests when adding new components
|
|
329
|
+
- Test implementation details
|
|
330
|
+
- Make tests dependent on each other
|
|
331
|
+
- Hardcode magic values
|
|
332
|
+
- Test Panda CSS internals
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## Related Documentation
|
|
337
|
+
|
|
338
|
+
- [STORY-002 Implementation](../context-share/STORY-002-IMPLEMENTATION-COMPLETE.md)
|
|
339
|
+
- [Three-Layer Architecture](../CLAUDE.md#architecture)
|
|
340
|
+
- [Shadow Token Architecture](../context-share/ELEVATION_FIX_PLAN.md)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Active Stories
|
|
2
|
+
|
|
3
|
+
Story specs for work in progress on the Discourser Design System. Each file is structured as a **self-contained prompt** — paste directly into Claude Code to execute.
|
|
4
|
+
|
|
5
|
+
## Execution Order
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
STORY-006a → STORY-006b → STORY-006c → STORY-011 → STORY-008
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
| # | File | Description | Estimate | Status |
|
|
12
|
+
|---|------|-------------|----------|--------|
|
|
13
|
+
| 1 | `STORY-006a-figma-translation-foundations.md` | Translation MDX files 00-04 (overview, colors, typography, spacing, shadows) | 1.5-2hr | Ready |
|
|
14
|
+
| 2 | `STORY-006b-figma-translation-components.md` | Translation MDX file 05 (all 25+ component mappings) | 2-3hr | Blocked on 006a |
|
|
15
|
+
| 3 | `STORY-006c-figma-translation-layout-extension.md` | Translation MDX files 06-07 (layout patterns, extension guide) | 1.5-2hr | Blocked on 006b |
|
|
16
|
+
| 4 | `STORY-011-verify-translation-docs.md` | Automated tests + verification scripts for translation accuracy | 2-3hr | Blocked on 006c |
|
|
17
|
+
| 5 | `STORY-008-kai-sidecar-fragments.md` | Extract condensed knowledge fragments for Kai agent | 2-3hr | Blocked on 011; executes in Discourser.ai repo |
|
|
18
|
+
|
|
19
|
+
## Lifecycle
|
|
20
|
+
|
|
21
|
+
When a story completes:
|
|
22
|
+
1. Move the file to `docs/context-share/` with completion notes appended
|
|
23
|
+
2. Update the corresponding Notion story status to Complete
|
|
24
|
+
3. Start the next story in sequence
|
|
25
|
+
|
|
26
|
+
## Parent Epic
|
|
27
|
+
|
|
28
|
+
**Kai Agent — Design System MCP Integration & Elevation Fix**
|
|
29
|
+
[Notion link](https://www.notion.so/3034d6019b428105a147e39a4fdb0a70)
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
# STORY-006a: Figma Translation System — Foundation Files (00-04)
|
|
2
|
+
|
|
3
|
+
> **Epic:** Kai Agent — Design System MCP Integration
|
|
4
|
+
> **Parent Story:** STORY-006: Figma-to-Discourser Translation System
|
|
5
|
+
> **Part:** 1 of 3
|
|
6
|
+
> **Estimate:** 1.5-2hr
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Context
|
|
11
|
+
|
|
12
|
+
We're building a Figma-to-Discourser translation system — a multi-file MDX documentation suite in Storybook that maps external design vocabulary (Figma, Tailwind, Shadcn) to Discourser Design System vocabulary (Panda CSS, Park UI, Ark UI).
|
|
13
|
+
|
|
14
|
+
This is the core translation layer for:
|
|
15
|
+
- The **Kai Design Engineer agent** (reads these docs via Storybook MCP to make token/component decisions)
|
|
16
|
+
- **Human developers** onboarding from Tailwind/Shadcn projects
|
|
17
|
+
- **Design System as a Service** clients receiving implementation specs
|
|
18
|
+
|
|
19
|
+
This prompt covers the **overview + token-level mapping files** (files 00-04). No component knowledge needed — just tokens verified against `panda.config.ts`.
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## Prerequisites — READ THESE FIRST
|
|
24
|
+
|
|
25
|
+
Before writing ANY code, read these files to understand the existing vocabulary and conventions:
|
|
26
|
+
|
|
27
|
+
1. `panda.config.ts` — The actual semantic tokens defined (fg.default, fg.muted, fg.subtle, canvas, border, radii l1/l2/l3, shadows). **This is the source of truth for every token name you reference.**
|
|
28
|
+
2. `src/preset/semantic-tokens.ts` — M3 semantic token definitions (surface, onSurface, outline, etc.)
|
|
29
|
+
3. `src/preset/shadows.ts` — Park UI shadow token scale
|
|
30
|
+
4. `stories/documentation/guidelines/design-tokens/colors.mdx` — Existing M3 color token docs
|
|
31
|
+
5. `stories/documentation/guidelines/design-tokens/spacing.mdx` — Existing spacing scale docs
|
|
32
|
+
6. `stories/documentation/guidelines/design-tokens/typography.mdx` — Existing typography scale docs
|
|
33
|
+
7. `stories/documentation/guidelines/design-tokens/elevation.mdx` — Existing shadow/elevation docs
|
|
34
|
+
8. `stories/documentation/guidelines/components/button.mdx` — Example of existing doc format (use as structure reference)
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Deliverables
|
|
39
|
+
|
|
40
|
+
Create directory: `stories/documentation/figma-translation/`
|
|
41
|
+
|
|
42
|
+
Create these 5 files:
|
|
43
|
+
|
|
44
|
+
### File 1: `00-FigmaTranslation.mdx`
|
|
45
|
+
|
|
46
|
+
**Storybook sidebar:** `Documentation/Figma Translation/00-Overview`
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
50
|
+
<Meta title="Documentation/Figma Translation/00-Overview" />
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Content:
|
|
54
|
+
- What this document suite is (translation layer between Figma/Tailwind/Shadcn vocabulary and Discourser)
|
|
55
|
+
- Who it's for (Kai agent, human developers onboarding from Tailwind/Shadcn projects)
|
|
56
|
+
- How to use it (look up the external term → get the Discourser equivalent)
|
|
57
|
+
- Architecture summary: Figma/Shadcn → Tailwind utilities → Discourser semantic tokens → Panda CSS output
|
|
58
|
+
- The 3-layer token architecture:
|
|
59
|
+
- **Layer 1 (Infrastructure):** Panda CSS / Park UI token names (`xs`, `sm`, `md`, `lg`, `xl`) — unchanging
|
|
60
|
+
- **Layer 2 (Design Language):** Material 3 — provides VALUES mapped to Layer 1 names — swappable
|
|
61
|
+
- **Layer 3 (Components):** Recipes reference Layer 1 only — decoupled from aesthetic
|
|
62
|
+
- Table of contents linking to all sub-pages (01 through 07)
|
|
63
|
+
|
|
64
|
+
### File 2: `01-Colors.mdx`
|
|
65
|
+
|
|
66
|
+
**Storybook sidebar:** `Documentation/Figma Translation/01-Colors`
|
|
67
|
+
|
|
68
|
+
Translation tables with THREE columns: **Source (Figma/Tailwind/Shadcn) | Discourser Token | Notes**
|
|
69
|
+
|
|
70
|
+
**Background colors section:**
|
|
71
|
+
|
|
72
|
+
| Source (Figma/Tailwind/Shadcn) | Discourser | Notes |
|
|
73
|
+
|---|---|---|
|
|
74
|
+
| `bg-background`, `bg-white` | `bg="canvas"` | Page-level background, resolves to gray.1 |
|
|
75
|
+
| `bg-card`, `bg-popover` | `bg="bg.default"` or use component (Card.Root handles this) | Surface containers |
|
|
76
|
+
| `bg-muted` | `bg="bg.muted"` | Subtle background areas |
|
|
77
|
+
| `bg-primary` | `colorPalette="primary"` (on components) or `bg="primary.9"` (raw) | Primary action surfaces |
|
|
78
|
+
| `bg-secondary` | `colorPalette="secondary"` or `bg="secondary.9"` | Secondary surfaces |
|
|
79
|
+
| `bg-destructive` | `colorPalette="error"` or `bg="error.9"` | Error/destructive surfaces |
|
|
80
|
+
| `bg-accent` | `bg="primary.a3"` or `bg="secondary.a3"` | Accent/highlight backgrounds |
|
|
81
|
+
|
|
82
|
+
**Text colors section:**
|
|
83
|
+
|
|
84
|
+
| Source | Discourser | Notes |
|
|
85
|
+
|---|---|---|
|
|
86
|
+
| `text-foreground` | `color="fg.default"` | Primary text, resolves to gray.12 |
|
|
87
|
+
| `text-muted-foreground` | `color="fg.muted"` | Secondary text, resolves to gray.11 |
|
|
88
|
+
| `text-primary` | `color="primary.11"` | Branded text |
|
|
89
|
+
| `text-destructive` | `color="error.11"` | Error text |
|
|
90
|
+
| `text-primary-foreground` | `color="primary.contrast"` | Text on primary backgrounds |
|
|
91
|
+
|
|
92
|
+
**Border colors section:**
|
|
93
|
+
|
|
94
|
+
| Source | Discourser | Notes |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `border`, `border-input` | `borderColor="border"` | Default border, resolves to gray.6 |
|
|
97
|
+
| `border-primary` | `borderColor="primary.7"` | Primary-colored borders |
|
|
98
|
+
|
|
99
|
+
**M3 Surface System section** (when Figma uses M3 vocabulary directly):
|
|
100
|
+
|
|
101
|
+
| Source (M3) | Discourser | Notes |
|
|
102
|
+
|---|---|---|
|
|
103
|
+
| `surface` | `bg="surface"` | M3 base surface |
|
|
104
|
+
| `surfaceContainer` | `bg="surface.container"` | M3 default container |
|
|
105
|
+
| `surfaceContainerLow` | `bg="surface.container.low"` | M3 low elevation |
|
|
106
|
+
| `surfaceContainerHigh` | `bg="surface.container.high"` | M3 high elevation |
|
|
107
|
+
| `surfaceContainerHighest` | `bg="surface.container.highest"` | M3 highest elevation |
|
|
108
|
+
| `onSurface` | `color="onSurface"` | Text on M3 surfaces |
|
|
109
|
+
| `onSurfaceVariant` | `color="onSurface.variant"` | Secondary text on M3 surfaces |
|
|
110
|
+
| `outline` | `borderColor="outline"` | M3 outline |
|
|
111
|
+
| `outlineVariant` | `borderColor="outline.variant"` | M3 subtle outline |
|
|
112
|
+
|
|
113
|
+
**Color Palette System section:**
|
|
114
|
+
- Explain the `colorPalette` prop system
|
|
115
|
+
- Rule: Components that support colorPalette prop → ALWAYS use colorPalette, not direct color tokens
|
|
116
|
+
- Available palettes: primary, secondary, tertiary, error, neutral/gray
|
|
117
|
+
- Radix scale explanation: 1-12 scale where 1=lightest, 12=darkest, 9=solid, a1-a12=alpha variants
|
|
118
|
+
- When to use `colorPalette="primary"` vs `bg="primary.9"` directly
|
|
119
|
+
|
|
120
|
+
**Common Mistakes section** with ❌/✅ examples:
|
|
121
|
+
```tsx
|
|
122
|
+
// ❌ WRONG: Hardcoded hex value
|
|
123
|
+
<Box bg="#4C662B">
|
|
124
|
+
|
|
125
|
+
// ❌ WRONG: Using Tailwind class name
|
|
126
|
+
<Box className="bg-primary">
|
|
127
|
+
|
|
128
|
+
// ❌ WRONG: Using raw Radix scale when component supports colorPalette
|
|
129
|
+
<Button bg="primary.9" color="primary.contrast">
|
|
130
|
+
|
|
131
|
+
// ✅ CORRECT: Semantic token
|
|
132
|
+
<Box bg="canvas">
|
|
133
|
+
|
|
134
|
+
// ✅ CORRECT: colorPalette on component
|
|
135
|
+
<Button colorPalette="primary">
|
|
136
|
+
|
|
137
|
+
// ✅ CORRECT: Radix scale for custom styling outside components
|
|
138
|
+
<Box bg="primary.3">
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Cross-reference: Link to `Documentation/Guidelines/99-Colors` for full M3 color role details.
|
|
142
|
+
|
|
143
|
+
### File 3: `02-Typography.mdx`
|
|
144
|
+
|
|
145
|
+
**Storybook sidebar:** `Documentation/Figma Translation/02-Typography`
|
|
146
|
+
|
|
147
|
+
**Tailwind → M3 textStyle mapping table:**
|
|
148
|
+
|
|
149
|
+
| Source (Tailwind) | Discourser | Size | Notes |
|
|
150
|
+
|---|---|---|---|
|
|
151
|
+
| `text-xs` | `textStyle="labelSmall"` | 11px | Smallest readable text |
|
|
152
|
+
| `text-sm` | `textStyle="bodySmall"` | 12px | Captions, help text |
|
|
153
|
+
| `text-base` | `textStyle="bodyMedium"` | 14px | Default body text |
|
|
154
|
+
| `text-lg` | `textStyle="bodyLarge"` | 16px | Emphasized body |
|
|
155
|
+
| `text-xl` | `textStyle="titleSmall"` | 14px/500wt | Card titles, list headers |
|
|
156
|
+
| `text-2xl` | `textStyle="titleLarge"` or `<Header size="xl">` | 22px | Section titles |
|
|
157
|
+
| `text-3xl` | `textStyle="headlineSmall"` or `<Header size="2xl">` | 24px | Page subtitles |
|
|
158
|
+
| `text-4xl` | `textStyle="headlineLarge"` or `<Header size="3xl">` | 32px | Page titles |
|
|
159
|
+
| `text-5xl`+ | `textStyle="displaySmall"` or `<Header size="4xl">` | 36px+ | Hero text |
|
|
160
|
+
|
|
161
|
+
**Font family mapping:**
|
|
162
|
+
|
|
163
|
+
| Source | Discourser | Font |
|
|
164
|
+
|---|---|---|
|
|
165
|
+
| `font-sans` | `fontFamily="body"` | Poppins |
|
|
166
|
+
| `font-serif` | `fontFamily="display"` | Fraunces |
|
|
167
|
+
| `font-mono` | `fontFamily="mono"` | JetBrains Mono |
|
|
168
|
+
|
|
169
|
+
**Font weight mapping:**
|
|
170
|
+
|
|
171
|
+
| Source | Discourser | Value |
|
|
172
|
+
|---|---|---|
|
|
173
|
+
| `font-normal` | `fontWeight="normal"` | 400 |
|
|
174
|
+
| `font-medium` | `fontWeight="medium"` | 500 |
|
|
175
|
+
| `font-semibold` | `fontWeight="semibold"` | 600 |
|
|
176
|
+
| `font-bold` | `fontWeight="bold"` | 700 |
|
|
177
|
+
|
|
178
|
+
**Header component section:**
|
|
179
|
+
- Rule: For headings, ALWAYS prefer `<Header size="...">` component over raw textStyle
|
|
180
|
+
- Available sizes: xs, sm, md, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl
|
|
181
|
+
- Header renders as h-tag levels — map Figma heading levels to component
|
|
182
|
+
|
|
183
|
+
**Common Mistakes** with ❌/✅ examples showing raw font-size vs textStyle vs Header component.
|
|
184
|
+
|
|
185
|
+
Cross-reference: Link to `Documentation/Guidelines/99-Typography` for full M3 type scale.
|
|
186
|
+
|
|
187
|
+
### File 4: `03-Spacing.mdx`
|
|
188
|
+
|
|
189
|
+
**Storybook sidebar:** `Documentation/Figma Translation/03-Spacing`
|
|
190
|
+
|
|
191
|
+
**Tailwind numeric → Panda CSS numeric mapping:**
|
|
192
|
+
|
|
193
|
+
| Source (Tailwind) | Discourser | Pixels | Notes |
|
|
194
|
+
|---|---|---|---|
|
|
195
|
+
| `p-0`, `gap-0` | `p="0"`, `gap="0"` | 0px | Direct match |
|
|
196
|
+
| `p-0.5` | `p="0.5"` | 2px | |
|
|
197
|
+
| `p-1` | `p="1"` | 4px | |
|
|
198
|
+
| `p-2` | `p="2"` | 8px | |
|
|
199
|
+
| `p-3` | `p="3"` | 12px | |
|
|
200
|
+
| `p-4` | `p="4"` | 16px | Most common |
|
|
201
|
+
| `p-5` | `p="5"` | 20px | |
|
|
202
|
+
| `p-6` | `p="6"` | 24px | |
|
|
203
|
+
| `p-8` | `p="8"` | 32px | |
|
|
204
|
+
| `p-10` | `p="10"` | 40px | |
|
|
205
|
+
| `p-12` | `p="12"` | 48px | |
|
|
206
|
+
| `p-16` | `p="16"` | 64px | |
|
|
207
|
+
|
|
208
|
+
**Named token mapping** (from spacing.mdx):
|
|
209
|
+
|
|
210
|
+
| Named Token | Numeric Equivalent | Pixels | Usage |
|
|
211
|
+
|---|---|---|---|
|
|
212
|
+
| `none` | `0` | 0px | Reset |
|
|
213
|
+
| `xxs` | `0.5` | 2px | Minimal gaps |
|
|
214
|
+
| `xs` | `1` | 4px | Tight spacing |
|
|
215
|
+
| `sm` | `2` | 8px | Compact layouts |
|
|
216
|
+
| `md` | `4` | 16px | Default spacing |
|
|
217
|
+
| `lg` | `6` | 24px | Comfortable spacing |
|
|
218
|
+
| `xl` | `8` | 32px | Major sections |
|
|
219
|
+
| `xxl` | `12` | 48px | Large sections |
|
|
220
|
+
| `xxxl` | `16` | 64px | Maximum spacing |
|
|
221
|
+
|
|
222
|
+
**Figma Auto-Layout translation section:**
|
|
223
|
+
|
|
224
|
+
| Figma Property | Discourser | Example |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| Auto-layout: Vertical, gap: 16 | `display="flex" flexDir="column" gap="4"` or `<VStack gap="4">` | Form fields |
|
|
227
|
+
| Auto-layout: Horizontal, gap: 8 | `display="flex" flexDir="row" gap="2"` or `<HStack gap="2">` | Button groups |
|
|
228
|
+
| Auto-layout: Wrap | `<Flex wrap="wrap" gap="4">` | Tag clouds |
|
|
229
|
+
| Padding: 16px all sides | `p="4"` | Card content |
|
|
230
|
+
| Padding: 24px H, 16px V | `px="6" py="4"` | Page sections |
|
|
231
|
+
| Padding: 16px top, 8px bottom | `pt="4" pb="2"` | Asymmetric spacing |
|
|
232
|
+
| Gap: 16px | `gap="4"` | Between siblings |
|
|
233
|
+
|
|
234
|
+
**Common Mistakes** with ❌/✅ examples showing pixel values vs token values.
|
|
235
|
+
|
|
236
|
+
Cross-reference: Link to `Documentation/Guidelines/99-Spacing`.
|
|
237
|
+
|
|
238
|
+
### File 5: `04-Shadows-Radii.mdx`
|
|
239
|
+
|
|
240
|
+
**Storybook sidebar:** `Documentation/Figma Translation/04-Shadows & Radii`
|
|
241
|
+
|
|
242
|
+
**Shadow mapping:**
|
|
243
|
+
|
|
244
|
+
| Source (Tailwind) | Discourser | M3 Level | Notes |
|
|
245
|
+
|---|---|---|---|
|
|
246
|
+
| `shadow-none` | `shadow="none"` | Level 0 | Flat |
|
|
247
|
+
| `shadow-sm` | `shadow="xs"` | — | Subtle lift |
|
|
248
|
+
| `shadow` | `shadow="sm"` | Level 1 | Cards |
|
|
249
|
+
| `shadow-md` | `shadow="md"` | Level 2 | Raised elements |
|
|
250
|
+
| `shadow-lg` | `shadow="lg"` | Level 3 | Dialogs, menus |
|
|
251
|
+
| `shadow-xl` | `shadow="xl"` | Level 4 | Drawers |
|
|
252
|
+
| `shadow-2xl` | `shadow="2xl"` | Level 5 | Modals |
|
|
253
|
+
|
|
254
|
+
Note: Verify exact Park UI shadow token names against `src/preset/shadows.ts`. The above mapping is approximate — confirm every token exists.
|
|
255
|
+
|
|
256
|
+
Include a note: M3 primarily uses surface tint (surfaceContainer colors) for elevation, not shadows alone. Shadows are supplementary.
|
|
257
|
+
|
|
258
|
+
**Border radius mapping:**
|
|
259
|
+
|
|
260
|
+
| Source (Tailwind) | Discourser | Pixels | Notes |
|
|
261
|
+
|---|---|---|---|
|
|
262
|
+
| `rounded-none` | `rounded="none"` | 0 | |
|
|
263
|
+
| `rounded-sm` | `rounded="l1"` | 2px | Subtle rounding |
|
|
264
|
+
| `rounded` | `rounded="l2"` | 6px | Default |
|
|
265
|
+
| `rounded-md` | `rounded="l2"` | 6px | Same as default |
|
|
266
|
+
| `rounded-lg` | `rounded="l3"` | 8px | Cards, dialogs |
|
|
267
|
+
| `rounded-xl` | `rounded="xl"` | 12px | Large cards |
|
|
268
|
+
| `rounded-2xl` | `rounded="2xl"` | 16px | Pills, large containers |
|
|
269
|
+
| `rounded-full` | `rounded="full"` | 9999px | Avatars, circular |
|
|
270
|
+
|
|
271
|
+
Note: Verify radii tokens. The l1/l2/l3 tokens are defined in panda.config.ts semanticTokens.radii. Standard Panda preset radii (xs, sm, md, lg, xl, 2xl, full) also exist from @pandacss/preset-panda.
|
|
272
|
+
|
|
273
|
+
**Common Mistakes** with ❌/✅ examples.
|
|
274
|
+
|
|
275
|
+
Cross-reference: Link to `Documentation/Guidelines/99-Elevation`.
|
|
276
|
+
|
|
277
|
+
---
|
|
278
|
+
|
|
279
|
+
## Technical Requirements
|
|
280
|
+
|
|
281
|
+
1. **Every MDX file must start with:**
|
|
282
|
+
```tsx
|
|
283
|
+
import { Meta } from '@storybook/addon-docs/blocks';
|
|
284
|
+
<Meta title="Documentation/Figma Translation/[XX-Name]" />
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
2. **Tables must use consistent columns across all files.** First column = external/source term. Second column = Discourser equivalent. This is non-negotiable — machine parsing depends on it.
|
|
288
|
+
|
|
289
|
+
3. **Each mapping entry must be self-contained** — an agent or human can look up a single row and get a complete answer without reading surrounding context.
|
|
290
|
+
|
|
291
|
+
4. **Verify EVERY token name against actual config files** before writing it in a table. Check:
|
|
292
|
+
- `panda.config.ts` semanticTokens section
|
|
293
|
+
- `src/preset/semantic-tokens.ts`
|
|
294
|
+
- `src/preset/shadows.ts`
|
|
295
|
+
- `src/preset/colors/` directory
|
|
296
|
+
|
|
297
|
+
If a token doesn't exist in config, DO NOT include it. Add a comment noting the gap instead.
|
|
298
|
+
|
|
299
|
+
5. **Run `pnpm storybook --no-open` briefly** after creating all files to verify MDX parses without errors. Kill after confirming no parse errors in terminal output.
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
## DO NOT
|
|
304
|
+
|
|
305
|
+
- Change any existing files outside the new `stories/documentation/figma-translation/` directory
|
|
306
|
+
- Modify `panda.config.ts` or any preset files
|
|
307
|
+
- Install any packages
|
|
308
|
+
- Create any `.stories.tsx` files — these are MDX documentation only
|
|
309
|
+
- Invent token names that don't exist in the config
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
## Acceptance Criteria
|
|
314
|
+
|
|
315
|
+
- [ ] `stories/documentation/figma-translation/` directory created
|
|
316
|
+
- [ ] `00-FigmaTranslation.mdx` — overview with architecture summary and links to all sub-pages
|
|
317
|
+
- [ ] `01-Colors.mdx` — complete color mapping (backgrounds, text, border, M3 surface, colorPalette system)
|
|
318
|
+
- [ ] `02-Typography.mdx` — complete typography mapping (text sizes, fonts, weights, Header component)
|
|
319
|
+
- [ ] `03-Spacing.mdx` — complete spacing mapping (numeric scale, named tokens, Figma auto-layout)
|
|
320
|
+
- [ ] `04-Shadows-Radii.mdx` — complete shadow + border-radius mapping
|
|
321
|
+
- [ ] Every token referenced verified against actual config files
|
|
322
|
+
- [ ] All files render in Storybook without MDX parse errors
|
|
323
|
+
- [ ] Common Mistakes (❌/✅) section in each file (01-04)
|
|
324
|
+
- [ ] Cross-references to existing Guidelines MDX docs
|