@trading-game/design-intelligence-layer 0.8.5 → 0.8.8

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.
@@ -0,0 +1,642 @@
1
+ # Trading Game Design System Guide
2
+
3
+ > **Package:** `@trading-game/design-intelligence-layer`
4
+ > **Audience:** AI agents and developers building UI for the Trading Game. This is the single source of truth for setting up and using the design system in any project.
5
+
6
+ ---
7
+
8
+ ## MANDATORY RULES — READ FIRST
9
+
10
+ ### Rule 1 — Component existence check
11
+
12
+ ```
13
+ BEFORE using any component:
14
+ 1. Check the Component Catalogue (Section 8). Does it exist?
15
+ YES → Import it from the npm package exactly as documented. Do NOT re-implement it.
16
+ NO → STOP. Tell the user:
17
+ "The [ComponentName] component does not exist in the Trading Game design system.
18
+ Options:
19
+ (a) Build a custom one using design system tokens only (no hardcoded colors or values)
20
+ (b) Use a different component that exists in the system
21
+ (c) Skip this component entirely"
22
+ Wait for the user to choose. Do NOT proceed without confirmation.
23
+ ```
24
+
25
+ ### Rule 2 — Token-only styling
26
+
27
+ ```
28
+ NEVER use:
29
+ ❌ Hardcoded hex: #2323FF, #FFFFFF, etc.
30
+ ❌ Raw Tailwind palette: bg-gray-100, text-zinc-500, text-slate-400, bg-black, bg-white
31
+ ❌ Raw opacity on non-tokens: bg-black/50 (use bg-overlay instead)
32
+ ❌ Arbitrary color values: bg-[#FF6600], text-[rgba(0,0,0,0.5)]
33
+ ❌ hsl(var(--token)) syntax — this is Tailwind v3. This project uses Tailwind v4.
34
+ ❌ Non-existent tokens: bg-hover, bg-badge-rank, text-primary-foreground, text-on-decorative
35
+ ❌ border-border — deprecated alias; use border-border-subtle or border-border-prominent
36
+
37
+ ALWAYS use semantic tokens:
38
+ ✅ bg-background, bg-card, bg-popover, bg-subtle, bg-overlay
39
+ ✅ text-on-prominent, text-on-subtle, text-on-muted
40
+ ✅ border-border-subtle, border-border-prominent, ring-ring
41
+ ✅ bg-primary, bg-primary-hover, bg-secondary-hover
42
+ ✅ text-semantic-win, text-semantic-loss, text-semantic-warning
43
+ ✅ Opacity on a token IS allowed: bg-primary/20, border-border-subtle/50, ring-primary/10
44
+ ```
45
+
46
+ ### Rule 3 — Layout utilities are exempt
47
+
48
+ ```
49
+ Tailwind layout/spacing utilities are freely usable for structural layout:
50
+ ✅ flex, grid, gap-4, p-6, m-2, w-full, h-screen, max-w-lg, col-span-2, etc.
51
+ ✅ z-50, overflow-hidden, transition-all, etc.
52
+
53
+ Token rules apply ONLY to:
54
+ - Color (background, text, border, ring, shadow color)
55
+ - Border radius (use the design system's radius scale — see Section 5)
56
+ - Typography (font family must use font-display or font-body, never raw font names)
57
+ ```
58
+
59
+ ### Rule 4 — Do NOT install or import these separately
60
+
61
+ ```
62
+ ❌ lucide-react — already bundled in the npm package
63
+ ❌ tailwindcss — the package ships its own Tailwind v4 config
64
+ ❌ @apply with hsl(var(--token)) — Tailwind v4 uses CSS variables directly
65
+ ❌ tailwind.config.js — configuration is handled by the package via CSS
66
+ ❌ Manual font-family in CSS — use font-display and font-body utility classes
67
+ ```
68
+
69
+ ### Rule 5 — Complexity-aware implementation
70
+
71
+ ```
72
+ Each component in the catalogue is tagged:
73
+ [simple] → Drop in, one import, works immediately
74
+ [composed] → Has required sub-components; use the full pattern shown
75
+ [complex] → Has significant state or setup; ask clarifying questions first
76
+ ```
77
+
78
+ ---
79
+
80
+ ## 1 — Quick Start
81
+
82
+ ### Step 1 — Install the package
83
+
84
+ ```bash
85
+ npm install @trading-game/design-intelligence-layer@latest --safe-chain-skip-minimum-package-age
86
+ ```
87
+
88
+ ### Step 2 — Add CSS imports
89
+
90
+ In your main CSS file (e.g. `globals.css` or `index.css`):
91
+
92
+ ```css
93
+ @import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap");
94
+ @import "tailwindcss";
95
+ @import "@trading-game/design-intelligence-layer/styles";
96
+ @source "../node_modules/@trading-game/design-intelligence-layer/dist";
97
+ ```
98
+
99
+ > **Note:** Fonts are loaded via a direct Google Fonts `@import` URL. Do NOT use `next/font`.
100
+
101
+ ### Step 3 — Set base HTML class
102
+
103
+ The design system is light-first. No extra class is required on `<html>` for the default light theme. A `.dark` class is reserved for future dark theme support but not yet styled.
104
+
105
+ ### Step 4 — Import components
106
+
107
+ ```tsx
108
+ import { Button, Card, Badge } from "@trading-game/design-intelligence-layer"
109
+ ```
110
+
111
+ ---
112
+
113
+ ## 2 — Design Tokens
114
+
115
+ > This is the single authoritative token reference. All tokens are defined as CSS variables in the package and mapped to Tailwind utility classes automatically.
116
+
117
+ ### 2.1 — Backgrounds
118
+
119
+ | CSS Variable | Tailwind Class | Usage |
120
+ | ---------------- | ---------------- | ------------------------- |
121
+ | `--background` | `bg-background` | Main page background |
122
+ | `--card` | `bg-card` | Cards, panels, modals |
123
+ | `--popover` | `bg-popover` | Popovers, elevated cards |
124
+ | `--subtle` | `bg-subtle` | Muted / secondary surfaces|
125
+ | `--overlay` | `bg-overlay` | Modal/dialog/drawer/sheet backdrop (semi-transparent) |
126
+ | `--tabs` | `bg-tabs` | Tab container / tab bar background (`variant="default"`) — 4% black alpha, adapts to any surface |
127
+ | `--tabs-active` | `bg-tabs-active` | Active / selected tab background — solid white |
128
+
129
+ ### 2.2 — Primary (Brand Blue)
130
+
131
+ | CSS Variable | Tailwind Class | Usage |
132
+ | --------------------- | ------------------- | ------------------------- |
133
+ | `--primary` | `bg-primary` / `text-primary` | Primary CTA, brand color, interactive elements |
134
+ | `--primary-hover` | `bg-primary-hover` | Hover & pressed states on primary elements |
135
+
136
+ ### 2.3 — Semantic (Trading Status)
137
+
138
+ | CSS Variable | Tailwind Class | Usage |
139
+ | -------------------- | ----------------------- | ------------------------- |
140
+ | `--semantic-win` | `text-semantic-win` / `bg-semantic-win` | Win / Profit / Positive outcomes |
141
+ | `--semantic-loss` | `text-semantic-loss` / `bg-semantic-loss` | Loss / Negative outcomes |
142
+ | `--semantic-warning` | `text-semantic-warning` / `bg-semantic-warning` | Warning / Caution / Non-destructive alerts |
143
+ | `--semantic-info` | `text-semantic-info` / `bg-semantic-info` | Informational alerts |
144
+
145
+ > All semantic tokens support opacity variants (e.g. `bg-semantic-warning/10` for tinted backgrounds). For structured alpha surfaces, use the primitive alpha scales — see Section 2.10.
146
+
147
+ ### 2.4 — Text & Icon Colors
148
+
149
+ | CSS Variable | Tailwind Class | Usage |
150
+ | ------------------------------- | --------------------------------------- | ------------------------- |
151
+ | `--on-prominent` | `text-on-prominent` | Primary text (headings, body) |
152
+ | `--on-prominent-static-inverse` | `text-on-prominent-static-inverse` | Always-white text (e.g. on primary blue buttons) |
153
+ | `--on-subtle` | `text-on-subtle` | Secondary text (descriptions, labels) |
154
+ | `--on-muted` | `text-on-muted` | Tertiary text (subtle labels, placeholders) |
155
+
156
+ ### 2.5 — Borders & Inputs
157
+
158
+ | CSS Variable | Tailwind Class | Usage |
159
+ | ------------------- | ------------------------- | ------------------------- |
160
+ | `--border-subtle` | `border-border-subtle` | Default light border |
161
+ | `--border-prominent`| `border-border-prominent` | Strong / emphasized border|
162
+ | `--input` | `border-input` | Input resting state border|
163
+ | `--ring` | `ring-ring` / `border-ring` | Focus ring and focus border color |
164
+
165
+ ### 2.6 — Supporting Colors
166
+
167
+ | CSS Variable | Tailwind Class | Usage |
168
+ | ------------------------ | -------------------- | ------------------------- |
169
+ | `--secondary-hover` | `bg-secondary-hover` | Hover bg on neutral elements (light gray) |
170
+ | `--slider-range` | `bg-slider-range` | Slider range fill (primary at 40%) |
171
+ | `--alert-info-text` | `text-alert-info-text` | Alert info text color |
172
+ | `--alert-info-border` | `border-alert-info-border` | Alert info border |
173
+ | `--alert-error-text` | `text-alert-error-text` | Alert error text color |
174
+ | `--alert-error-border` | `border-alert-error-border` | Alert error border |
175
+
176
+ > **Accent (orange) and Violet:** `--primitive-orange-500` and `--primitive-violet-500` are available as CSS variables only (no Tailwind utility class). Use `var(--primitive-orange-500)` directly for rank badges and special highlights.
177
+
178
+ ### 2.7 — Opacity Patterns
179
+
180
+ | Usage | Tailwind Class |
181
+ | ------------------------------ | ---------------------- |
182
+ | Subtle hover tint | `bg-primary/[0.08]` |
183
+ | Medium highlight | `bg-primary/[0.16]` |
184
+ | Selected/active tint | `bg-primary/10` |
185
+ | Status badge tint backgrounds | `bg-semantic-win/10`, `bg-semantic-loss/10`, etc. |
186
+
187
+ ### 2.8 — Interactive States
188
+
189
+ > **`bg-hover` does not exist.** Use `bg-secondary-hover` or `bg-primary/[0.08]` for hover states.
190
+
191
+ **Universal pattern for interactive list/row/chip elements** (except Button and Tabs which have their own):
192
+
193
+ | State | Background | Text |
194
+ | -------- | -------------------- | ---------------------------------- |
195
+ | Default | transparent | `text-on-prominent` or `text-on-subtle` |
196
+ | Hover | `bg-secondary-hover` | `text-primary` |
197
+ | Selected | `bg-secondary-hover` | `text-primary font-semibold` |
198
+
199
+ > **NEVER** use `bg-accent` or `text-accent-foreground`. Do NOT add borders to selected states.
200
+
201
+ ### 2.9 — Transitions
202
+
203
+ **Duration tokens:**
204
+
205
+ | Tailwind Class | CSS Variable | Value | Usage |
206
+ | ----------------- | ------------------------------ | ------ | -------------------------------------- |
207
+ | `duration-instant`| `--primitive-duration-instant` | `50ms` | Focus rings, hover color tints |
208
+ | `duration-fast` | `--primitive-duration-fast` | `100ms`| Buttons, inputs, badges, checkboxes |
209
+ | `duration-base` | `--primitive-duration-base` | `200ms`| Dropdowns, popovers, accordions |
210
+ | `duration-slow` | `--primitive-duration-slow` | `300ms`| Dialogs, sheets, drawers closing |
211
+ | `duration-open` | `--primitive-duration-open` | `500ms`| Sheets, drawers entering |
212
+
213
+ **Easing tokens:**
214
+
215
+ | Tailwind Class | CSS Variable | Value | Usage |
216
+ | ---------------- | ----------------------------- | ------------------------------ | -------------------------------------- |
217
+ | `ease-standard` | `--primitive-ease-standard` | `cubic-bezier(0.2, 0, 0, 1)` | General UI — bidirectional state changes |
218
+ | `ease-enter` | `--primitive-ease-enter` | `cubic-bezier(0, 0, 0.2, 1)` | Overlays / surfaces entering |
219
+ | `ease-exit` | `--primitive-ease-exit` | `cubic-bezier(0.4, 0, 1, 1)` | Overlays / surfaces leaving |
220
+ | `ease-linear` | `--primitive-ease-linear` | `linear` | Sidebar width, progress bar |
221
+
222
+ **Usage pattern:**
223
+
224
+ ```tsx
225
+ <div className="transition-colors duration-fast ease-standard">...</div>
226
+ ```
227
+
228
+ ### 2.10 — Primitive Alpha Scales
229
+
230
+ > Raw alpha (opacity) variants of the mono and blue primitives. These are **internal CSS variables only** — not exposed as Tailwind utility classes. Reference them only from semantic tokens, never directly in components.
231
+
232
+ **Naming convention:** `--primitive-[color]-alpha-[stop]`
233
+
234
+ **Mono alpha scale** (black — `oklch(0 0 0 / X%)`)
235
+
236
+ | CSS Variable | Opacity | Typical use |
237
+ | ----------------------------- | ------- | ---------------------------------------- |
238
+ | `--primitive-mono-alpha-4` | 4% | Tab container background (`--tabs`) |
239
+ | `--primitive-mono-alpha-8` | 8% | Subtle hover tint |
240
+ | `--primitive-mono-alpha-16` | 16% | Pressed / active surface tint |
241
+ | `--primitive-mono-alpha-24` | 24% | Medium-weight tinted surface |
242
+ | `--primitive-mono-alpha-32` | 32% | Disabled state overlay |
243
+ | `--primitive-mono-alpha-40` | 40% | Strong tint / scrim |
244
+ | `--primitive-mono-alpha-50` | 50% | Backdrop overlay (replaces `--primitive-black-50`) |
245
+ | `--primitive-mono-alpha-64` | 64% | Heavy overlay |
246
+ | `--primitive-mono-alpha-80` | 80% | Near-opaque overlay |
247
+
248
+ **Blue alpha scale** (brand blue — `oklch(0.476 0.297 267.4 / X%)`)
249
+
250
+ | CSS Variable | Opacity | Typical use |
251
+ | ----------------------------- | ------- | ---------------------------------------- |
252
+ | `--primitive-blue-alpha-4` | 4% | Extremely subtle brand tint |
253
+ | `--primitive-blue-alpha-8` | 8% | Hover tint on brand surfaces |
254
+ | `--primitive-blue-alpha-16` | 16% | Selected / active brand tint |
255
+ | `--primitive-blue-alpha-24` | 24% | Medium brand surface highlight |
256
+ | `--primitive-blue-alpha-32` | 32% | Strong brand tint |
257
+ | `--primitive-blue-alpha-40` | 40% | Slider range fill (via `--slider-range`) |
258
+ | `--primitive-blue-alpha-50` | 50% | Brand overlay |
259
+ | `--primitive-blue-alpha-64` | 64% | Heavy brand overlay |
260
+ | `--primitive-blue-alpha-80` | 80% | Near-opaque brand overlay |
261
+
262
+ > **`--primitive-black-50` is deprecated.** It now aliases `--primitive-mono-alpha-50`. The `--overlay` semantic token is unaffected — it still resolves to the same 50% black value.
263
+
264
+ ---
265
+
266
+ ## 3 — AI Agent Decision Rules
267
+
268
+ > Quick-lookup table: "If I need X, use Y, never Z."
269
+
270
+ | IF you need to... | THEN use | NEVER use |
271
+ | -------------------------------------- | --------------------------------- | -------------------------------------- |
272
+ | Pick a primary CTA button color | `bg-primary` | Green, or any other color for primary CTA |
273
+ | Show WIN / profit / positive | `text-semantic-win` | Primary blue for profit |
274
+ | Show LOSS / negative | `text-semantic-loss` | Any non-token red |
275
+ | Show WARNING / caution | `text-semantic-warning` | Raw orange hex or primary tint |
276
+ | Color a tab container background | `bg-tabs` | `bg-subtle` for tabs |
277
+ | Color an active/selected tab | `bg-tabs-active` | `bg-background` for active tab |
278
+ | Color a page background | `bg-background` | `bg-white` directly |
279
+ | Color a modal/dialog backdrop | `bg-overlay` | `bg-black/50` or raw black opacity |
280
+ | Color a card or panel | `bg-card` | Arbitrary gray |
281
+ | Color an elevated surface (popover) | `bg-popover` | `bg-card` for popovers |
282
+ | Write primary heading text | `text-on-prominent` | Pure white, raw hex colors |
283
+ | Write body / description text | `text-on-subtle` | `text-on-prominent` for descriptions |
284
+ | Write a subtle label | `text-on-muted` | `text-on-subtle` for the subtlest text |
285
+ | Add a default border | `border-border-subtle` | Solid black borders, `border-border` |
286
+ | Add a strong border | `border-border-prominent` | — |
287
+ | Style an input (resting) | `border-input` | Solid colored backgrounds |
288
+ | Style an input (focused) | `border-ring` + `ring-[3px] ring-ring/50` | Generic shadows on inputs |
289
+ | Pick a heading font | `font-display` | System fonts, raw font-family names |
290
+ | Pick a body font | `font-body` | Raw font-family names |
291
+ | Style button text | `font-display font-bold`, sentence case | `uppercase` on buttons |
292
+ | Write white text on a dark surface | `text-on-prominent-static-inverse`| `text-white` or raw white hex |
293
+
294
+ ---
295
+
296
+ ## 4 — Typography
297
+
298
+ ### 4.1 — Font Setup
299
+
300
+ All text uses **Plus Jakarta Sans** (loaded weights: 300–800). Three Tailwind aliases are available — they all resolve to the same font:
301
+
302
+ | Tailwind Class | Purpose |
303
+ | --------------- | ------------------------------- |
304
+ | `font-display` | Headings, wordmark, buttons |
305
+ | `font-body` | Body text, UI elements |
306
+ | `font-sans` | Default sans-serif fallback |
307
+
308
+ ### 4.2 — Pre-built Typography Classes
309
+
310
+ The npm package ships these ready-to-use CSS classes. All include `text-transform: uppercase`:
311
+
312
+ | Class | Size | Line Height | Weight | Letter Spacing |
313
+ | ------------- | ----- | ----------- | ------ | -------------- |
314
+ | `heading-h1` | 72px | 72px | 600 | 1.5px |
315
+ | `heading-h2` | 64px | 64px | 600 | 1.5px |
316
+ | `heading-h3` | 48px | 48px | 600 | 1.5px |
317
+ | `heading-h4` | 40px | 40px | 600 | 1.5px |
318
+ | `heading-xs` | 24px | 24px | 600 | 1.5px |
319
+ | `body-lg` | 18px | 28px | 600 | — |
320
+ | `body-md` | 16px | 24px | 600 | — |
321
+ | `body-sm` | 12px | 16px | 600 | — |
322
+ | `body-xs` | 8px | 12px | 600 | — |
323
+
324
+ **Responsive heading sizes** (headings scale down on mobile):
325
+
326
+ | Class | Desktop | Mobile |
327
+ | ------------ | ------- | ------ |
328
+ | `heading-h1` | 72px | 48px |
329
+ | `heading-h2` | 64px | 48px |
330
+ | `heading-h3` | 48px | 40px |
331
+ | `heading-h4` | 40px | 32px |
332
+ | `heading-xs` | 24px | 20px |
333
+
334
+ ### 4.3 — Custom Text Size Overrides
335
+
336
+ These sizes differ from standard Tailwind defaults — use the design system values:
337
+
338
+ | Class | Size | Line Height | How it differs from Tailwind |
339
+ | ----------- | ------ | ----------- | ---------------------------- |
340
+ | `text-xxs` | 8px | 12px | Custom (not in standard TW) |
341
+ | `text-2xl` | 24px | **24px** | Line height differs (TW: 32px) |
342
+ | `text-3xl` | **32px** | **32px** | Size differs (TW: 30px) |
343
+ | `text-4xl` | **40px** | **40px** | Size differs (TW: 36px) |
344
+ | `text-6xl` | **64px** | **64px** | Size differs (TW: 60px) |
345
+
346
+ > All other `text-*` sizes (`xs`, `sm`, `base`, `lg`, `xl`, `5xl`, `7xl`, `8xl`, `9xl`) match standard Tailwind.
347
+
348
+ ### 4.4 — Typography Usage Rules
349
+
350
+ | Context | Class | Weight |
351
+ | ------------------------ | -------------- | ------------------- |
352
+ | Page headings | `font-display` | `font-semibold` (600) |
353
+ | Button labels | `font-display` | `font-bold` (700), sentence case |
354
+ | Body text | `font-body` | `font-semibold` (600) |
355
+ | Tiny labels / decorative | `font-body` | `font-semibold` (600) at 8px |
356
+
357
+ ### 4.5 — Letter Spacing Tokens
358
+
359
+ | Token value | Usage |
360
+ | ----------- | ------------------------ |
361
+ | 1.5px | Buttons, headings |
362
+ | -0.4px | Paragraphs, tight text |
363
+ | -0.8px | Tight display text |
364
+
365
+ ---
366
+
367
+ ## 5 — Border Radius
368
+
369
+ The design system uses a custom radius scale (base = 10px). Use these named tokens instead of arbitrary values:
370
+
371
+ | Tailwind Class | Value |
372
+ | -------------- | ------ |
373
+ | `rounded-2xs` | 2px |
374
+ | `rounded-xs` | 4px |
375
+ | `rounded-sm` | 6px |
376
+ | `rounded-md` | 8px |
377
+ | `rounded-lg` | 10px |
378
+ | `rounded-xl` | 14px |
379
+ | `rounded-2xl` | 18px |
380
+ | `rounded-3xl` | 22px |
381
+ | `rounded-4xl` | 26px |
382
+ | `rounded-full` | 9999px |
383
+
384
+ > **Important:** Do NOT use `rounded-[4px]` or `rounded-[2px]` — use `rounded-xs` and `rounded-2xs` instead. Arbitrary radius values should only be used for sizes not in this scale (e.g. `rounded-[24px]`, `rounded-[32px]`).
385
+
386
+ ---
387
+
388
+ ## 6 — Button System
389
+
390
+ ### 6.1 — Variants
391
+
392
+ | Variant | Background | Text Color | Border | Hover |
393
+ | ----------- | ---------------------- | ---------------------------------- | ----------------------------------- | ----------------------- |
394
+ | `primary` | `bg-primary` | `text-on-prominent-static-inverse` | none | `bg-primary-hover` |
395
+ | `secondary` | transparent | `text-on-prominent` | `border-[1.5px] border-border-prominent` | `bg-secondary-hover` |
396
+ | `tertiary` | transparent | `text-primary` | none | `bg-primary/[0.08]` |
397
+
398
+ ### 6.2 — Sizes
399
+
400
+ | Size | Height | Padding X | Font Size | Icon Size | Radius |
401
+ | --------- | ------ | --------- | --------- | --------- | ------ |
402
+ | `lg` | 48px | 24px | 16px | 16px | 4px |
403
+ | `md` | 40px | 16px | 14px | 16px | 4px |
404
+ | `sm` | 32px | 12px | 12px | 14px | 4px |
405
+ | `xs` | 24px | 8px | 12px | 12px | 4px |
406
+
407
+ **Icon-only sizes:**
408
+
409
+ | Size | Dimensions | Icon Size |
410
+ | ---------- | ---------- | --------- |
411
+ | `icon-lg` | 48×48px | 16px |
412
+ | `icon-md` | 40×40px | 16px |
413
+ | `icon-sm` | 28×28px | 16px |
414
+ | `icon-xs` | 24×24px | 12px |
415
+
416
+ ### 6.3 — Button Typography & States
417
+
418
+ All buttons: `font-display font-bold`, sentence case (no `uppercase`, no `tracking-wide`).
419
+
420
+ | State | Behavior |
421
+ | -------- | ------------------------------------------------ |
422
+ | Default | Base styling per variant |
423
+ | Hover | Color shift per variant (see above) |
424
+ | Focus | 3px ring with `ring-ring/50` opacity |
425
+ | Pressed | `active:opacity-60` |
426
+ | Loading | `opacity-50`, `pointer-events-none`, `data-loading`, `aria-busy` |
427
+ | Disabled | `opacity-50`, `pointer-events-none` |
428
+
429
+ ---
430
+
431
+ ## 7 — Responsive Layout
432
+
433
+ ### 7.1 — Layout Grid
434
+
435
+ | Breakpoint | Viewport | Columns | Gutter | Margin |
436
+ | ---------- | ---------- | ------- | ------ | ------ |
437
+ | Default | 0–319px | 1 | 0 | 16px |
438
+ | Small | 320–599px | 4 | 16px | 16px |
439
+ | Medium | 600–1135px | 8 | 36px | 36px |
440
+ | Large | 1136px+ | 12 | 36px | 64px |
441
+
442
+ **Tailwind utilities:** `gap-layout-gutter`, `px-layout-margin-inline`.
443
+
444
+ **CSS variables for custom grids:** `var(--semantic-layout-grid-columns)`, `var(--spacing-layout-gutter)`, `var(--spacing-layout-margin-inline)`.
445
+
446
+ ### 7.2 — Responsive Spacing Tokens
447
+
448
+ | Token | Desktop | Mobile |
449
+ | -------------------- | ------- | ------ |
450
+ | container-padding-x | 24px | 16px |
451
+ | section-padding-y | 96px | 64px |
452
+ | section-title-gap-xl | 24px | 20px |
453
+ | section-title-gap-lg | 20px | 16px |
454
+ | section-title-gap-md | 20px | 16px |
455
+ | section-title-gap-sm | 16px | 16px |
456
+
457
+ ---
458
+
459
+ ## 8 — Available Components
460
+
461
+ > **All components below are exported from `@trading-game/design-intelligence-layer`.**
462
+ > - If a component is listed → import and use it. Do NOT re-implement.
463
+ > - If NOT listed → STOP and ask the user (see Rule 1).
464
+ > - For props, variants, sizes, and sub-components → inspect the package's TypeScript types after installation.
465
+
466
+ ### Import pattern
467
+
468
+ All components use the same import path:
469
+
470
+ ```tsx
471
+ import { Button, Card, Badge } from "@trading-game/design-intelligence-layer"
472
+ ```
473
+
474
+ ### Example — composed component with sub-components
475
+
476
+ ```tsx
477
+ import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter, DialogClose } from "@trading-game/design-intelligence-layer"
478
+
479
+ <Dialog>
480
+ <DialogTrigger asChild><Button>Open</Button></DialogTrigger>
481
+ <DialogContent showCloseButton>
482
+ <DialogHeader>
483
+ <DialogTitle>Title</DialogTitle>
484
+ <DialogDescription>Description text.</DialogDescription>
485
+ </DialogHeader>
486
+ <div>Content here</div>
487
+ <DialogFooter>
488
+ <Button variant="primary" size="md">Confirm</Button>
489
+ </DialogFooter>
490
+ </DialogContent>
491
+ </Dialog>
492
+ ```
493
+
494
+ ### Component list
495
+
496
+ > **Complexity tags:** `[simple]` = drop in, one import | `[composed]` = has required sub-components | `[complex]` = has significant state/setup, ask the user first
497
+
498
+ | Component | Tag | Sub-components |
499
+ |-----------|-----|----------------|
500
+ | Accordion | [composed] | AccordionItem, AccordionTrigger, AccordionContent |
501
+ | Alert | [composed] | AlertTitle, AlertDescription |
502
+ | AlertDialog | [complex] | AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogAction, AlertDialogCancel, AlertDialogMedia |
503
+ | AspectRatio | [simple] | — |
504
+ | Avatar | [composed] | AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup, AvatarGroupCount |
505
+ | Badge | [simple] | — |
506
+ | Breadcrumb | [composed] | BreadcrumbList, BreadcrumbItem, BreadcrumbLink, BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis |
507
+ | Button | [simple] | — |
508
+ | Calendar | [complex] | — |
509
+ | Card | [composed] | CardHeader, CardTitle, CardDescription, CardContent, CardFooter, CardAction |
510
+ | Carousel | [complex] | CarouselContent, CarouselItem, CarouselPrevious, CarouselNext |
511
+ | Chart | [complex] | ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle |
512
+ | Checkbox | [simple] | — |
513
+ | Collapsible | [composed] | CollapsibleTrigger, CollapsibleContent |
514
+ | Combobox | [complex] | ComboboxInput, ComboboxContent, ComboboxList, ComboboxItem, ComboboxEmpty, ComboboxGroup, ComboboxLabel |
515
+ | Command | [complex] | CommandDialog, CommandInput, CommandList, CommandEmpty, CommandGroup, CommandItem, CommandSeparator, CommandShortcut |
516
+ | ContextMenu | [composed] | ContextMenuTrigger, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuLabel, ContextMenuCheckboxItem, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSub, ContextMenuSubTrigger, ContextMenuSubContent |
517
+ | Dialog | [complex] | DialogTrigger, DialogContent, DialogHeader, DialogFooter, DialogTitle, DialogDescription, DialogClose |
518
+ | DirectionProvider | [simple] | — |
519
+ | Drawer | [complex] | DrawerTrigger, DrawerContent, DrawerHeader, DrawerFooter, DrawerTitle, DrawerDescription, DrawerClose |
520
+ | DropdownMenu | [composed] | DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuCheckboxItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent, DropdownMenuShortcut |
521
+ | Empty | [composed] | EmptyHeader, EmptyMedia, EmptyTitle, EmptyDescription, EmptyContent |
522
+ | Field | [complex] | FieldLabel, FieldDescription, FieldError, FieldGroup, FieldLegend, FieldSet, FieldContent, FieldTitle, FieldSeparator |
523
+ | Form | [complex] | FormField, FormItem, FormLabel, FormControl, FormDescription, FormMessage |
524
+ | HoverCard | [composed] | HoverCardTrigger, HoverCardContent |
525
+ | Input | [simple] | — |
526
+ | InputGroup | [composed] | InputGroupAddon, InputGroupInput, InputGroupButton, InputGroupText, InputGroupTextarea |
527
+ | InputOTP | [composed] | InputOTPGroup, InputOTPSlot, InputOTPSeparator |
528
+ | Item | [composed] | ItemGroup, ItemContent, ItemTitle, ItemDescription, ItemMedia, ItemActions, ItemHeader, ItemFooter, ItemSeparator |
529
+ | Kbd | [simple] | KbdGroup |
530
+ | Label | [simple] | — |
531
+ | Link | [simple] | — |
532
+ | Menubar | [complex] | MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarSub, MenubarSubTrigger, MenubarSubContent, MenubarShortcut |
533
+ | NavigationMenu | [complex] | NavigationMenuList, NavigationMenuItem, NavigationMenuTrigger, NavigationMenuContent, NavigationMenuLink, NavigationMenuIndicator, NavigationMenuViewport, navigationMenuTriggerStyle |
534
+ | NativeSelect | [simple] | NativeSelectOption, NativeSelectOptGroup |
535
+ | Pagination | [composed] | PaginationContent, PaginationItem, PaginationLink, PaginationPrevious, PaginationNext, PaginationEllipsis |
536
+ | Popover | [composed] | PopoverTrigger, PopoverContent, PopoverHeader, PopoverTitle, PopoverDescription |
537
+ | Progress | [simple] | — |
538
+ | RadioGroup | [composed] | RadioGroupItem |
539
+ | Resizable | [complex] | ResizablePanelGroup, ResizablePanel, ResizableHandle |
540
+ | ScrollArea | [simple] | ScrollBar |
541
+ | Select | [composed] | SelectTrigger, SelectValue, SelectContent, SelectGroup, SelectLabel, SelectItem, SelectSeparator |
542
+ | Separator | [simple] | — |
543
+ | Sheet | [complex] | SheetTrigger, SheetContent, SheetHeader, SheetFooter, SheetTitle, SheetDescription, SheetClose |
544
+ | Sidebar | [complex] | SidebarProvider, SidebarTrigger, SidebarInset, SidebarHeader, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton, SidebarRail, useSidebar |
545
+ | Skeleton | [simple] | — |
546
+ | Slider | [simple] | — |
547
+ | Sonner (Toaster) | [simple] | — (also import `toast` from `sonner`) |
548
+ | Spinner | [simple] | — |
549
+ | Switch | [simple] | — |
550
+ | Table | [composed] | TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption |
551
+ | Tabs | [composed] | TabsList (`variant`: default/line, `size`: sm/md/lg), TabsTrigger (`iconPosition`: inline/top), TabsContent. Root accepts `orientation`: horizontal/vertical. |
552
+ | Textarea | [simple] | — |
553
+ | TicketCard | [composed] | — |
554
+ | Toggle | [simple] | — |
555
+ | ToggleGroup | [composed] | ToggleGroupItem |
556
+ | Tooltip | [composed] | TooltipTrigger, TooltipContent, TooltipProvider |
557
+
558
+ ### Component styling notes
559
+
560
+ These are styling behaviors you can't discover from TypeScript types alone:
561
+
562
+ | Component | Note |
563
+ |-----------|------|
564
+ | Button | `font-display font-bold`, sentence case (no `uppercase`). Primary: `text-on-prominent-static-inverse`. Tertiary hover: `bg-primary/[0.08]` |
565
+ | Card | Flat by default (no shadow). Add elevation manually: `className="shadow-sm"` |
566
+ | Input | Resting: `border-input`. Focus: `border-ring` + `ring-[3px] ring-ring/50`. Radius: `rounded-sm` (6px) |
567
+ | Tooltip | Bubble: `bg-primary` + `text-on-prominent-static-inverse` (not `bg-popover`). Always wrap in `<TooltipProvider>` |
568
+ | Sidebar | Menu buttons use `rounded-sm`. Selection: `bg-secondary-hover` + `text-primary` + `font-semibold` |
569
+ | Breadcrumb | Active page: `text-primary font-medium`. Links: `text-on-subtle` |
570
+ | Tabs | **Variants:** `default` (pill, `bg-tabs`) and `line` (underline, transparent bg). **Sizes:** `sm` (h-8, text-xs), `md` (h-10, text-sm, default), `lg` (h-12, text-base). **Icon position:** `inline` (default) or `top` (stacks icon above label). **Orientation:** `horizontal` (default) or `vertical` (line variant renders left-edge indicator). Hover: `bg-secondary-hover` (default) / `text-primary` (line). Selected: `bg-tabs-active` + `text-primary font-semibold`. Line variant underline: `bg-primary`. |
571
+ | Select | Item hover: `bg-primary/[0.08]`. Selected: `text-primary font-medium` + checkmark. `SelectTrigger` accepts `readOnly` prop: blocks interaction, retains full default appearance, chevron renders at `opacity-30` |
572
+ | Progress | Track: `bg-primary/20`. Indicator: `bg-primary`. Radius: `rounded-2xs` |
573
+ | Spinner | Inherits parent text color. **Always pass `text-primary` for standalone use** |
574
+ | Switch | Checked track: `bg-slider-range`. Checked thumb: `bg-primary` |
575
+ | Slider | Thumb: square `rounded-[4px]`, `bg-primary`. Track range: `bg-slider-range` |
576
+ | Dialog/Sheet | Footer buttons should use `size="md"`. Overlay: `bg-overlay` |
577
+ | Menubar | Hover: `bg-primary/[0.08]`. Open state: `bg-primary/10` |
578
+ | Toggle | Pressed: `bg-primary/10` + `border-primary` + `text-primary` |
579
+ | Calendar | Selected: `bg-secondary-hover` + `text-primary font-bold`. Today: primary dot below date |
580
+
581
+ ---
582
+
583
+ ## 9 — Common Mistakes
584
+
585
+ | Mistake | Correct Approach |
586
+ | ------- | ---------------- |
587
+ | Using hardcoded hex (`#2323FF`) for primary | Use `bg-primary` or `text-primary` |
588
+ | Using `bg-white` or `bg-black` | Use `bg-background` or `bg-overlay` |
589
+ | Using `border-border` | Use `border-border-subtle` or `border-border-prominent` |
590
+ | Using `bg-hover` | Use `bg-primary/[0.08]` or `bg-secondary-hover` |
591
+ | Using `text-primary-foreground` | Use `text-on-prominent-static-inverse` |
592
+ | Using `text-on-decorative` | Use `text-on-muted` |
593
+ | Using `font-mono` expecting Plus Jakarta Sans | Use `font-display` or `font-body` |
594
+ | Using `font-bold` for headings | Use `font-semibold` (600) for headings |
595
+ | Using `uppercase` on buttons | Buttons use sentence case (no `uppercase`) |
596
+ | Using standard TW sizes for headings (e.g. `text-6xl` = 60px) | Use design system values (`text-6xl` = 64px in this system) |
597
+ | Forgetting responsive heading sizes | Headings scale down on mobile (see Section 4.2) |
598
+ | Using `rounded-[4px]` or `rounded-[2px]` | Use `rounded-xs` (4px) or `rounded-2xs` (2px) |
599
+ | Installing `lucide-react` separately | Already bundled — import icons directly |
600
+ | Adding `tailwind.config.js` | Tailwind v4 uses CSS config via the package |
601
+ | Using `bg-gray-*`, `text-zinc-*`, etc. | Use semantic tokens only |
602
+
603
+ ---
604
+
605
+ ## 10 — Accessibility Notes
606
+
607
+ 1. **Primary blue text on white** (~3.0:1) — reserve for large/bold UI labels only.
608
+ 2. **Secondary text `text-on-subtle` on white** (~4.5:1) — meets WCAG AA for normal text.
609
+ 3. **Tertiary text `text-on-muted` on white** (~7.0:1) — safe for all sizes.
610
+ 4. **Win green on white** (~5.0:1) — safe for normal text at AA.
611
+ 5. **Loss red on white** (~3.9:1) — use at 18px+ bold or pair with icons.
612
+ 6. Always pair semantic colors with **icons or labels** — never communicate meaning through color alone.
613
+
614
+ ---
615
+
616
+ ## Quick Reference — Code Snippets
617
+
618
+ **Primary CTA:**
619
+ ```tsx
620
+ <Button variant="primary" size="lg">Trade Now</Button>
621
+ ```
622
+
623
+ **Profit/Loss display:**
624
+ ```tsx
625
+ <span className="text-semantic-win font-body font-semibold">+$84.00</span>
626
+ <span className="text-semantic-loss font-body font-semibold">-$120.00</span>
627
+ ```
628
+
629
+ **Heading:**
630
+ ```tsx
631
+ <h1 className="heading-h1">Trading Game</h1>
632
+ ```
633
+
634
+ **Body text:**
635
+ ```tsx
636
+ <p className="body-md">Your portfolio summary for today.</p>
637
+ ```
638
+
639
+ **Input with focus styling:**
640
+ ```tsx
641
+ <Input type="email" placeholder="Enter your email" />
642
+ ```
@@ -199,7 +199,7 @@ When the user asks to **update**, **upgrade**, or **install the latest** `@tradi
199
199
  3. **Notify on replace** — If you **delete, replace, or substantially overwrite** local component code to match the package, **stop and tell the user clearly**, e.g.
200
200
  `Aligned [ComponentName] with @trading-game/design-intelligence-layer@[version]. Previous local behavior or classes: [short summary]. Re-apply needs via package variants/props, tokens, or a thin wrapper only if product requires it.`
201
201
  4. **Review `className` overrides** — Parent apps often pass `className` on DS components. Old overrides (radius, colors, shadows) can **hide** new defaults (e.g. pill buttons). After upgrade, scan for overrides on DS components and trim or adjust them when they conflict with the new design.
202
- 5. **Refresh Cursor rules** — The package ships `docs/rules/design-system-consuming-project.mdc`. Cursor does **not** read it from `node_modules` automatically. Tell the user to re-copy it (see README **AI Agent Setup → Cursor**) so agent instructions match the release.
202
+ 5. **Refresh Cursor rules** — The package ships `guides/rules/design-system-consuming-project.mdc`. Cursor does **not** read it from `node_modules` automatically. Tell the user to re-copy it (see README **AI Agent Setup → Cursor**) so agent instructions match the release.
203
203
  6. **Tailwind** — Confirm `@source` still points at `node_modules/@trading-game/design-intelligence-layer/dist` so Tailwind v4 emits classes from the updated bundle.
204
204
 
205
205
  ### Do not assume
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trading-game/design-intelligence-layer",
3
- "version": "0.8.5",
3
+ "version": "0.8.8",
4
4
  "description": "Trading Game Design System — shadcn/ui components with Tailwind CSS v4",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -34,7 +34,7 @@
34
34
  "files": [
35
35
  "dist/",
36
36
  "src/styles.css",
37
- "docs/",
37
+ "guides/",
38
38
  "AGENTS.md"
39
39
  ],
40
40
  "publishConfig": {