@deriv-ds/design-intelligence-layer 0.1.0

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/AGENTS.md ADDED
@@ -0,0 +1,71 @@
1
+ # AI Agent Instructions — @trading-game/design-intelligence-layer
2
+
3
+ This file is read automatically by AI coding agents (Cursor, Windsurf, Claude Code, Copilot, and others) to understand how to build with this design system correctly.
4
+
5
+ ---
6
+
7
+ ## Step 1 — Read all design intelligence files first
8
+
9
+ Before building any landing page, product screen, game view, or feature UI, you MUST read all four files:
10
+
11
+ **Design principles** — the decision framework for every layout, hierarchy, motion, copy, and component choice:
12
+ ```
13
+ node_modules/@trading-game/design-intelligence-layer/guides/design-principles/trading-game-design-principles.md
14
+ ```
15
+
16
+ **Accessibility standards** — the inclusion standard every screen must meet (WCAG 2.1 AA):
17
+ ```
18
+ node_modules/@trading-game/design-intelligence-layer/guides/accessibility-standards/trading-game-accessibility-standards.md
19
+ ```
20
+
21
+ **Personas** — the three player modes (Edge Seeker, System Runner, Public Predictor) that shape all copy and UX decisions:
22
+ ```
23
+ node_modules/@trading-game/design-intelligence-layer/guides/personas/trading-game-player-field-guide.md
24
+ ```
25
+
26
+ **Brand voice** — channel-specific voice application, banned phrases, vocabulary reference, and formatting rules for all player-facing copy:
27
+ ```
28
+ node_modules/@trading-game/design-intelligence-layer/guides/brand-voice/trading-game-brand-voice.md
29
+ ```
30
+
31
+ All four files apply to all projects built with this package — landing pages, product screens, and games.
32
+
33
+ Run the checklists at the end of the design principles and accessibility standards files before considering any screen complete. Use the personas and brand voice to guide all player-facing copy.
34
+
35
+ ---
36
+
37
+ ## Step 2 — Read the component and token rules
38
+
39
+ You MUST also follow the full agent rules file:
40
+
41
+ ```
42
+ node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc
43
+ ```
44
+
45
+ **Cursor users:** Copy this file into `.cursor/rules/` after every package upgrade:
46
+
47
+ ```bash
48
+ cp node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc .cursor/rules/
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Step 3 — Core rules summary
54
+
55
+ 1. **Check before building** — if a component exists in `@trading-game/design-intelligence-layer`, import it. Never re-implement it.
56
+ 2. **Tokens only** — use semantic token classes (`bg-prominent`, `text-on-prominent`, `border-border`, etc.). Never hardcode hex values, raw Tailwind palette colors, or CSS variables.
57
+ 3. **Design principles and accessibility first** — every screen must reflect the 8 design principles and meet the accessibility standards (WCAG 2.1 AA). Run both checklists before shipping.
58
+ 4. **No separate installs** — do not install `lucide-react`, `tailwindcss`, or other bundled dependencies separately.
59
+ 5. **After a version bump** — re-copy the rules file into `.cursor/rules/`, check for stale local component copies, and align them with the package.
60
+ 6. **Blocks are playground-only** — Blocks (e.g. NavBar) appear in the playground's Blocks tab but are **not** exported from the package. Do not try to import them. To build a block pattern in a consuming project, compose it manually using package components and design tokens. See `guides/design-system-guide/trading-game-ds-guide.md` Section 8.5.
61
+
62
+ ---
63
+
64
+ ## Reference
65
+
66
+ - Full token + component reference: `node_modules/@trading-game/design-intelligence-layer/README.md`
67
+ - Design principles: `node_modules/@trading-game/design-intelligence-layer/guides/design-principles/trading-game-design-principles.md`
68
+ - Accessibility standards: `node_modules/@trading-game/design-intelligence-layer/guides/accessibility-standards/trading-game-accessibility-standards.md`
69
+ - Personas: `node_modules/@trading-game/design-intelligence-layer/guides/personas/trading-game-player-field-guide.md`
70
+ - Brand voice: `node_modules/@trading-game/design-intelligence-layer/guides/brand-voice/trading-game-brand-voice.md`
71
+ - Full agent rules: `node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc`
package/README.md ADDED
@@ -0,0 +1,544 @@
1
+ # Trading Game Design System
2
+
3
+ A component library and design token system for the Trading Game product. Built on [shadcn/ui](https://ui.shadcn.com/) with a custom Figma-driven token architecture, Tailwind CSS v4, and React 19.
4
+
5
+ Published as **`@trading-game/design-intelligence-layer`** on npm.
6
+
7
+ ---
8
+
9
+ ## Quick Start
10
+
11
+ ### Installation
12
+
13
+ ```bash
14
+ npm install @trading-game/design-intelligence-layer@latest --safe-chain-skip-minimum-package-age
15
+ ```
16
+
17
+ > **Note:** The `--safe-chain-skip-minimum-package-age` flag bypasses npm's 72-hour safe-chain hold on newly published packages. Required when the latest version was published less than 72 hours ago (common for AI agents and CI pipelines).
18
+
19
+ ### 1. Add the CSS imports
20
+
21
+ In your main CSS file (e.g. `globals.css`), add these three lines **in this order**:
22
+
23
+ ```css
24
+ @import "@trading-game/design-intelligence-layer/styles";
25
+ @import "tailwindcss";
26
+ @source "../node_modules/@trading-game/design-intelligence-layer/dist";
27
+ ```
28
+
29
+ > **Why `@source`?** Tailwind v4 skips `node_modules` by default. Without this line, Tailwind won't generate CSS for the component classes. Adjust the path if your CSS file is not one level below `node_modules` (e.g. in a monorepo use `../../node_modules/...`).
30
+
31
+ ### 1b. Vite projects — add the Tailwind plugin
32
+
33
+ If your project uses **Vite** (e.g. Vite + React), you must add the Tailwind CSS plugin to your Vite config:
34
+
35
+ ```bash
36
+ npm install @tailwindcss/vite
37
+ ```
38
+
39
+ ```js
40
+ // vite.config.js
41
+ import react from '@vitejs/plugin-react'
42
+ import tailwindcss from '@tailwindcss/vite'
43
+
44
+ export default {
45
+ plugins: [react(), tailwindcss()],
46
+ }
47
+ ```
48
+
49
+ > **Next.js projects** do not need this — Next.js uses PostCSS for Tailwind automatically.
50
+
51
+ ### 2. Fonts (handled automatically)
52
+
53
+ The styles import loads **Plus Jakarta Sans** from Google Fonts automatically. No additional font setup is needed.
54
+
55
+ Use `font-body`, `font-display`, or `font-sans` in your Tailwind classes — all resolve to Plus Jakarta Sans.
56
+
57
+ ### 3. Use components
58
+
59
+ ```tsx
60
+ import { Button, Card, Badge } from "@trading-game/design-intelligence-layer"
61
+
62
+ export default function App() {
63
+ return (
64
+ <Card>
65
+ <Button variant="primary">Trade Now</Button>
66
+ <Badge>Live</Badge>
67
+ </Card>
68
+ )
69
+ }
70
+ ```
71
+
72
+ ### Peer dependencies
73
+
74
+ Make sure these are installed in your project:
75
+
76
+ ```bash
77
+ npm install react react-dom tailwindcss
78
+ ```
79
+
80
+ > Requires React 18+ and Tailwind CSS v4+.
81
+
82
+ ---
83
+
84
+ ## What's inside
85
+
86
+ - **54 UI components** — buttons, forms, dialogs, charts, sidebars, and more
87
+ - **Design tokens** — CSS custom properties for color, radius, typography, and transitions synced from Figma
88
+ - **Transition tokens** — semantic duration and easing tokens (`duration-base`, `ease-standard`, etc.) — no hardcoded `duration-200` anywhere
89
+ - **Light-only theme** — white backgrounds, black text, primary blue accents — no dark mode
90
+ - **Typography classes** — heading scale (h1–xs) and body scale (lg–xs) ready to use
91
+ - **TypeScript** — full type definitions included
92
+ - **ESM + CJS** — works with any bundler
93
+
94
+ ---
95
+
96
+ ## Available components
97
+
98
+ | Component | Import |
99
+ |---|---|
100
+ | Accordion | `Accordion, AccordionItem, AccordionTrigger, AccordionContent` |
101
+ | Alert | `Alert, AlertTitle, AlertDescription` |
102
+ | Alert Dialog | `AlertDialog, AlertDialogTrigger, AlertDialogContent, ...` |
103
+ | Avatar | `Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup` |
104
+ | Badge | `Badge, badgeVariants` |
105
+ | Breadcrumb | `Breadcrumb, BreadcrumbList, BreadcrumbItem, ...` |
106
+ | Button | `Button, buttonVariants` |
107
+ | Calendar | `Calendar, CalendarDayButton` |
108
+ | Card | `Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter` |
109
+ | Carousel | `Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext` |
110
+ | Chart | `ChartContainer, ChartTooltip, ChartLegend, ChartStyle` |
111
+ | Checkbox | `Checkbox` |
112
+ | Collapsible | `Collapsible, CollapsibleTrigger, CollapsibleContent` |
113
+ | Combobox | `Combobox, ComboboxInput, ComboboxContent, ComboboxItem, ...` |
114
+ | Command | `Command, CommandDialog, CommandInput, CommandList, ...` |
115
+ | Context Menu | `ContextMenu, ContextMenuTrigger, ContextMenuContent, ...` |
116
+ | Dialog | `Dialog, DialogTrigger, DialogContent, DialogHeader, ...` |
117
+ | Drawer | `Drawer, DrawerTrigger, DrawerContent, DrawerHeader, ...` |
118
+ | Dropdown Menu | `DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ...` |
119
+ | Empty State | `Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent` |
120
+ | Field | `Field, FieldLabel, FieldDescription, FieldError, FieldGroup` |
121
+ | Form | `Form, FormItem, FormLabel, FormControl, FormField, FormMessage` |
122
+ | Hover Card | `HoverCard, HoverCardTrigger, HoverCardContent` |
123
+ | Input | `Input` |
124
+ | Input Group | `InputGroup, InputGroupAddon, InputGroupButton, InputGroupText` |
125
+ | Input OTP | `InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator` |
126
+ | Item | `Item, ItemMedia, ItemContent, ItemTitle, ItemDescription` |
127
+ | Kbd | `Kbd, KbdGroup` |
128
+ | Label | `Label` |
129
+ | Link | `Link` |
130
+ | Menubar | `Menubar, MenubarMenu, MenubarTrigger, MenubarContent, ...` |
131
+ | Native Select | `NativeSelect, NativeSelectOptGroup, NativeSelectOption` |
132
+ | Navigation Menu | `NavigationMenu, NavigationMenuList, NavigationMenuTrigger, ...` |
133
+ | Pagination | `Pagination, PaginationContent, PaginationLink, ...` |
134
+ | Popover | `Popover, PopoverTrigger, PopoverContent, PopoverAnchor` |
135
+ | Progress | `Progress` |
136
+ | Radio Group | `RadioGroup, RadioGroupItem` |
137
+ | Resizable | `ResizableHandle, ResizablePanel, ResizablePanelGroup` |
138
+ | Scroll Area | `ScrollArea, ScrollBar` |
139
+ | Select | `Select, SelectTrigger, SelectContent, SelectItem, ...` |
140
+ | Separator | `Separator` |
141
+ | Sheet | `Sheet, SheetTrigger, SheetContent, SheetHeader, ...` |
142
+ | Sidebar | `Sidebar, SidebarProvider, SidebarMenu, SidebarMenuItem, ...` |
143
+ | Skeleton | `Skeleton` |
144
+ | Slider | `Slider` |
145
+ | Spinner | `Spinner` |
146
+ | Switch | `Switch` |
147
+ | Table | `Table, TableHeader, TableBody, TableRow, TableHead, TableCell` |
148
+ | Tabs | `Tabs, TabsList, TabsTrigger, TabsContent` |
149
+ | Textarea | `Textarea` |
150
+ | Ticket Card | `TicketCard` |
151
+ | Toast | `Toaster` |
152
+ | Toggle | `Toggle, toggleVariants` |
153
+ | Toggle Group | `ToggleGroup, ToggleGroupItem` |
154
+ | Tooltip | `Tooltip, TooltipTrigger, TooltipContent, TooltipProvider` |
155
+
156
+ ---
157
+
158
+ ## Blocks
159
+
160
+ Blocks are pre-composed UI patterns built from design system primitives. They are demonstrated in the **Blocks** tab of the development playground and are **not** exported from the npm package — import the underlying components directly if you need to use them.
161
+
162
+ | Block | Variants | Description |
163
+ |---|---|---|
164
+ | NavBar | Desktop, Mobile (closed), Mobile (open) | Landing page top navigation bar. Logo + ghost nav links (Products, Use Cases, Docs, Blog, FAQ) + Sign in / Sign up CTAs. |
165
+ | Hero | Type 1 (Desktop + Mobile), Type 2 | Landing page hero sections. Type 1: tagline pill + heading + body + CTAs left, image right (responsive). Type 2: centred single-column, tagline pill + heading + body + primary CTA with arrow icon, no image. |
166
+
167
+ ---
168
+
169
+ ## Button variants and sizes
170
+
171
+ ```tsx
172
+ <Button variant="primary" /> // Blue filled (#2323FF) — main CTA
173
+ <Button variant="secondary" /> // Black outline — secondary actions
174
+ <Button variant="tertiary" /> // Text only, underline on hover — minimal
175
+
176
+ // Sizes
177
+ <Button size="lg" /> // 48px height (default)
178
+ <Button size="md" /> // 40px height
179
+ <Button size="sm" /> // 32px height
180
+ <Button size="xs" /> // 24px height
181
+ <Button size="icon-lg" /> // 48px square
182
+ <Button size="icon-md" /> // 40px square
183
+ <Button size="icon-sm" /> // 28px square
184
+ <Button size="icon-xs" /> // 24px square
185
+ ```
186
+
187
+ ## Badge variants
188
+
189
+ ```tsx
190
+ // Default (solid)
191
+ <Badge variant="default" /> // Blue (#2323FF)
192
+ <Badge variant="default-success" /> // Green
193
+ <Badge variant="default-fail" /> // Red
194
+
195
+ // Fill (tint background)
196
+ <Badge variant="fill" /> // Blue tint
197
+ <Badge variant="fill-success" /> // Green tint
198
+ <Badge variant="fill-fail" /> // Red tint
199
+
200
+ // Outline (black border, secondary-hover on hover)
201
+ <Badge variant="outline" />
202
+
203
+ // Ghost (transparent)
204
+ <Badge variant="ghost" />
205
+ <Badge variant="ghost-success" />
206
+ <Badge variant="ghost-fail" />
207
+
208
+ // Sizes
209
+ <Badge size="sm" /> // 24px height
210
+ <Badge size="md" /> // 32px height (default)
211
+ <Badge size="lg" /> // 40px height
212
+ ```
213
+
214
+ ## Alert variants
215
+
216
+ ```tsx
217
+ <Alert variant="info" /> // blue — informational (default)
218
+ <Alert variant="error" /> // red — error state
219
+ ```
220
+
221
+ ## Component behaviour notes
222
+
223
+ ### AlertDialog — button fill
224
+ `AlertDialogAction` and `AlertDialogCancel` fill the full container width **only** when `size="sm"`. On `size="default"` (the default), buttons are natural width and right-aligned.
225
+
226
+ ```tsx
227
+ <AlertDialogContent size="sm"> // buttons fill width (50/50 grid)
228
+ <AlertDialogContent size="default"> // buttons natural width, right-aligned
229
+ ```
230
+
231
+ ### Drawer — footer buttons
232
+ `DrawerFooter` makes all direct child buttons fill the full width automatically via `[&>*]:w-full`. Stack your buttons inside `DrawerFooter` and they will always be full-width.
233
+
234
+ ### Link — size lg
235
+ The `lg` variant of `Link` uses `text-base` (16px). The `md` and `sm` variants use `text-sm` (14px) and `text-xs` (12px) respectively.
236
+
237
+ ```tsx
238
+ <Link size="lg" /> // 16px — font-base
239
+ <Link size="md" /> // 14px — font-sm
240
+ <Link size="sm" /> // 12px — font-xs
241
+ ```
242
+
243
+ ### Tabs — line variant hover
244
+ On the `line` variant, hover state shows `text-primary` (blue) with no background fill. On the `default` (pill) variant, hover shows a grey background with `text-on-prominent`.
245
+
246
+ ---
247
+
248
+ ## Design tokens
249
+
250
+ All tokens are CSS custom properties, loaded automatically via `@trading-game/design-intelligence-layer/styles`.
251
+
252
+ ### Background tokens
253
+
254
+ | Tailwind class | CSS variable | Value | Usage |
255
+ |---|---|---|---|
256
+ | `bg-prominent` | `--prominent` | `#FFFFFF` | Page background |
257
+ | `bg-card` | `--card` | `#FFFFFF` | Card/panel surface |
258
+ | `bg-popover` | `--popover` | `#FFFFFF` | Popover/dropdown surface |
259
+ | `bg-subtle` | `--subtle` | `#F5F5F5` | Subtle tinted surface |
260
+ | `bg-overlay` | `--overlay` | black 50% | Modal/dialog backdrop only |
261
+ | `bg-tabs` | `--tabs` | black 4% alpha | Tab container background (`variant="default"`) |
262
+ | `bg-tabs-active` | `--tabs-active` | `#FFFFFF` | Active / selected tab pill |
263
+ | `bg-primary` | `--primary` | `#2323FF` | Brand blue — CTAs |
264
+ | `bg-primary-hover` | `--primary-hover` | `#0B0BD2` | Primary button hover (darker blue) |
265
+ | `bg-secondary-hover` | `--secondary-hover` | `#EEEEEE` | Outline/secondary hover (light grey) |
266
+ | `bg-semantic-win` | `--semantic-win` | green | Profit / positive state |
267
+ | `bg-semantic-loss` | `--semantic-loss` | red | Loss / negative state |
268
+
269
+ ### Text tokens
270
+
271
+ | Tailwind class | Value | Usage |
272
+ |---|---|---|
273
+ | `text-on-prominent` | `#000000` | Primary text on light backgrounds |
274
+ | `text-on-prominent-static-inverse` | `#FFFFFF` | Always white — for text on dark/primary backgrounds |
275
+ | `text-on-subtle` | mid grey | Secondary / supporting text |
276
+
277
+ | `text-primary` | `#2323FF` | Brand blue inline text |
278
+ | `text-semantic-win` | green | Profit / positive text |
279
+ | `text-semantic-loss` | red | Loss / negative text |
280
+
281
+ ### Border & focus tokens
282
+
283
+ | Tailwind class | CSS variable | Value | Usage |
284
+ |---|---|---|---|
285
+ | `border-border-subtle` | `--border-subtle` | `#EEEEEE` | **Default** — cards, dividers, form borders |
286
+ | `border-border-prominent` | `--border-prominent` | `#000000` | Outline variant components (button, badge, toggle) |
287
+ | `border-border` | `--border` | `#EEEEEE` | @deprecated alias — prefer `border-border-subtle` |
288
+ | `border-input` | `--input` | `#EEEEEE` | Input field borders |
289
+ | `ring-ring` | `--ring` | `#2323FF` | Focus rings |
290
+
291
+ > ⚠️ **`border-border` vs `border-border-subtle`:** Both resolve to the same light grey `#EEEEEE`. `border-border` is kept for backward compatibility. **Prefer `border-border-subtle` in all new code.**
292
+
293
+ ### Transition tokens
294
+
295
+ Duration — primitive scale:
296
+
297
+ | Tailwind class | CSS variable | Value | Used for |
298
+ |---|---|---|---|
299
+ | `duration-instant` | `--primitive-duration-instant` | `50ms` | Focus rings, hover tints |
300
+ | `duration-fast` | `--primitive-duration-fast` | `100ms` | Buttons, inputs, badges |
301
+ | `duration-base` | `--primitive-duration-base` | `200ms` | Dropdowns, popovers, accordions |
302
+ | `duration-slow` | `--primitive-duration-slow` | `300ms` | Dialogs, sheets, drawers closing |
303
+ | `duration-open` | `--primitive-duration-open` | `500ms` | Sheets, drawers entering |
304
+
305
+ Easing — primitive scale:
306
+
307
+ | Tailwind class | CSS variable | Value | Used for |
308
+ |---|---|---|---|
309
+ | `ease-standard` | `--primitive-ease-standard` | `cubic-bezier(0.2, 0, 0, 1)` | General UI — bidirectional state changes |
310
+ | `ease-enter` | `--primitive-ease-enter` | `cubic-bezier(0, 0, 0.2, 1)` | Overlays / surfaces entering |
311
+ | `ease-exit` | `--primitive-ease-exit` | `cubic-bezier(0.4, 0, 1, 1)` | Overlays / surfaces leaving |
312
+ | `ease-linear` | `--primitive-ease-linear` | `linear` | Sidebar width, progress bar |
313
+
314
+ > Always use token utilities — never raw `duration-200` or `ease-in-out` directly.
315
+
316
+ ### Other tokens
317
+
318
+ | Tailwind class | Value | Usage |
319
+ |---|---|---|
320
+ | `bg-slider-range` | blue 40% | Slider filled range |
321
+ | `rounded-lg` | `0.625rem` | Base border radius |
322
+
323
+ ### Using opacity with tokens
324
+
325
+ Opacity on tokens is allowed and encouraged:
326
+
327
+ ```
328
+ ✅ bg-primary/20 → blue at 20% opacity
329
+ ✅ border-border-subtle/50 → light grey border at 50% opacity
330
+ ✅ ring-ring/10 → ring at 10% opacity
331
+
332
+ ❌ bg-black/50 → NOT a token, use bg-overlay instead
333
+ ❌ bg-white → NOT a token, use bg-prominent or bg-card
334
+ ```
335
+
336
+ ### Primitive alpha scales
337
+
338
+ For structured alpha surfaces, the design system ships two internal alpha primitive scales. These are **CSS variables only** — not exposed as Tailwind utility classes. Always reference them via a semantic token, never directly in components.
339
+
340
+ ```
341
+ --primitive-mono-alpha-4 through --primitive-mono-alpha-80 (black at N%)
342
+ --primitive-blue-alpha-4 through --primitive-blue-alpha-80 (brand blue at N%)
343
+ Stops: 4 · 8 · 16 · 24 · 32 · 40 · 50 · 64 · 80
344
+ ```
345
+
346
+ Example — how `--tabs` uses the alpha scale:
347
+ ```css
348
+ --tabs: var(--primitive-mono-alpha-4); /* black at 4% — tab container background */
349
+ ```
350
+
351
+ > `--primitive-black-50` is deprecated. It now aliases `--primitive-mono-alpha-50`. The `--overlay` semantic token is unaffected.
352
+
353
+ ---
354
+
355
+ ## Typography
356
+
357
+ The styles export includes pre-built typography classes using **Plus Jakarta Sans**.
358
+
359
+ ### Heading scale (Semibold 600 · tracking 1.5px · uppercase)
360
+
361
+ | Class | Size / Line height |
362
+ |---|---|
363
+ | `heading-h1` | 72px / 72px |
364
+ | `heading-h2` | 64px / 64px |
365
+ | `heading-h3` | 48px / 48px |
366
+ | `heading-h4` | 40px / 40px |
367
+ | `heading-xs` | 24px / 24px |
368
+
369
+ ### Body scale (Semibold 600)
370
+
371
+ | Class | Size / Line height |
372
+ |---|---|
373
+ | `body-lg` | 18px / 28px |
374
+ | `body-md` | 16px / 24px |
375
+ | `body-sm` | 12px / 16px |
376
+ | `body-xs` | 8px / 12px |
377
+
378
+ ### Font utilities
379
+
380
+ | Tailwind class | Font |
381
+ |---|---|
382
+ | `font-display` | Plus Jakarta Sans — headings, display text |
383
+ | `font-body` or `font-sans` | Plus Jakarta Sans — body text |
384
+
385
+ ---
386
+
387
+ ## Upgrading the design system
388
+
389
+ When you bump `@trading-game/design-intelligence-layer` and run `npm install` (or `npm ci`):
390
+
391
+ | How you use the package | What happens |
392
+ |-------------------------|----------------|
393
+ | You **import** components only from `@trading-game/design-intelligence-layer` | After install and a rebuild, your app uses the **new** implementations in `node_modules/.../dist` — buttons, cards, etc. reflect the version you installed. |
394
+ | You **copied** `components/ui/*` (or similar) into your repo | Those files **do not** auto-update. You must delete them and switch to package imports, or manually merge changes from the new package. |
395
+
396
+ **Overrides:** Passing large `className` strings onto DS components can mask new defaults (e.g. old radius after a “pill button” update). After upgrading, review those callsites.
397
+
398
+ **Cursor / AI agents:** The package ships agent rules at `node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc`. Cursor does **not** load rules from `node_modules` by default — **re-copy** that file into `.cursor/rules/` after each upgrade so instructions match the release (same command as in **AI Agent Setup** below). The rules include **Rule 7 — Package version upgrades**: agents should search for duplicated components, align with the package, and **tell you explicitly** if local component code was replaced.
399
+
400
+ ---
401
+
402
+ ## AI Agent Setup
403
+
404
+ ### All AI tools (Cursor, Windsurf, Claude Code, Copilot, and others)
405
+
406
+ The package ships an `AGENTS.md` file that most AI tools read automatically. After installing the package, copy it to your project root:
407
+
408
+ ```bash
409
+ cp node_modules/@trading-game/design-intelligence-layer/AGENTS.md ./AGENTS.md
410
+ ```
411
+
412
+ This tells any AI agent to:
413
+ 1. Read the design principles before building any screen
414
+ 2. Follow the component and token rules
415
+ 3. Run the 7-point checklist before completing any view
416
+
417
+ **Design principles file** (bundled in the package):
418
+ ```
419
+ node_modules/@trading-game/design-intelligence-layer/guides/design-principles/trading-game-design-principles.md
420
+ ```
421
+
422
+ **Accessibility standards file** (bundled in the package):
423
+ ```
424
+ node_modules/@trading-game/design-intelligence-layer/guides/accessibility-standards/trading-game-accessibility-standards.md
425
+ ```
426
+
427
+ **Personas file** (bundled in the package):
428
+ ```
429
+ node_modules/@trading-game/design-intelligence-layer/guides/personas/trading-game-player-field-guide.md
430
+ ```
431
+
432
+ **Brand voice** (bundled in the package):
433
+ ```
434
+ node_modules/@trading-game/design-intelligence-layer/guides/brand-voice/trading-game-brand-voice.md
435
+ ```
436
+
437
+ All four files apply to all projects built with this package — landing pages, product screens, and games. Every AI agent must read all of them before starting any build. Run the design principles and accessibility checklists before completing any screen. Use the personas and brand voice to guide all player-facing copy.
438
+
439
+ ### Cursor
440
+
441
+ Copy the included rule file into your project:
442
+
443
+ ```bash
444
+ mkdir -p .cursor/rules
445
+ cp node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc .cursor/rules/
446
+ ```
447
+
448
+ Re-run this **`cp` after every design-system version bump** so your workspace rules stay in sync with the installed package.
449
+
450
+ ### Claude Code
451
+
452
+ Add the following to your project's `CLAUDE.md`:
453
+
454
+ ```markdown
455
+ ## Design System
456
+
457
+ This project uses @trading-game/design-intelligence-layer. Before writing any UI:
458
+ 1. Read node_modules/@trading-game/design-intelligence-layer/guides/design-principles/trading-game-design-principles.md — apply the 8 principles and run the 7-point checklist on every screen
459
+ 2. Read node_modules/@trading-game/design-intelligence-layer/guides/accessibility-standards/trading-game-accessibility-standards.md — apply WCAG 2.1 AA standards and run the 9-point accessibility checklist on every screen
460
+ 3. Read node_modules/@trading-game/design-intelligence-layer/guides/personas/trading-game-player-field-guide.md — understand the 3 player modes (Edge Seeker, System Runner, Public Predictor) that shape all copy and UX
461
+ 4. Read node_modules/@trading-game/design-intelligence-layer/guides/brand-voice/trading-game-brand-voice.md — apply the brand voice: channel-specific voice, banned phrases, vocabulary, and formatting rules for all player-facing copy
462
+ 5. Check if the component exists in the package — import it, don't re-implement
463
+ 6. Use only design token classes (bg-prominent, text-on-prominent, border-border-subtle, etc.) — no hardcoded hex or raw Tailwind palette colors
464
+ 7. Do not install lucide-react, tailwindcss, or other bundled dependencies separately
465
+ 8. If no token exists for a value, ask before using a hardcoded value
466
+ 9. After upgrading the package: prefer package imports over local copies of components; if replacing local UI code with the package version, tell the user what was overwritten; re-copy guides/rules/design-system-consuming-project.mdc into .cursor/rules if using Cursor
467
+
468
+ See node_modules/@trading-game/design-intelligence-layer/guides/rules/design-system-consuming-project.mdc for full rules.
469
+ See node_modules/@trading-game/design-intelligence-layer/README.md for complete token and component reference.
470
+ ```
471
+
472
+ ---
473
+
474
+ ## Common mistakes
475
+
476
+ | Wrong | Right | Why |
477
+ |---|---|---|
478
+ | `bg-gray-100` | `bg-subtle` | Raw Tailwind palette — use tokens |
479
+ | `bg-white` | `bg-prominent` or `bg-card` | Not a semantic token |
480
+ | `text-white` | `text-on-prominent-static-inverse` | Use the semantic inverse token |
481
+ | `text-black` | `text-on-prominent` | Not a semantic token |
482
+ | `bg-black/50` | `bg-overlay` | Overlay has its own token |
483
+ | `bg-[#2323FF]` | `bg-primary` | Hardcoded hex — use token |
484
+ | `border-border` | `border-border-subtle` | Old name — prefer the new explicit name |
485
+ | `bg-[var(--primary)]` | `bg-primary` | Raw CSS var — Tailwind v4 maps tokens directly |
486
+ | `hsl(var(--primary))` | `bg-primary` | Tailwind v3 syntax — not needed in v4 |
487
+ | Installing `lucide-react` | Already bundled | Icons are included in the package |
488
+
489
+ ---
490
+
491
+ ## Do NOT install separately
492
+
493
+ These are bundled with the package. Installing them separately can cause version conflicts:
494
+
495
+ - `lucide-react` — icon library
496
+ - `radix-ui` — headless primitives
497
+ - `class-variance-authority` — variant API
498
+ - `cmdk` — command palette
499
+ - `vaul` — drawer
500
+ - `sonner` — toast
501
+ - `recharts` — charts
502
+ - `react-day-picker` — calendar
503
+ - `embla-carousel-react` — carousel
504
+ - `react-resizable-panels` — resizable panels
505
+
506
+ ---
507
+
508
+ ## Development (contributors only)
509
+
510
+ ```bash
511
+ # Clone
512
+ git clone https://github.com/trading-game/TG-design-system.git
513
+ cd TG-design-system
514
+
515
+ # Install dependencies
516
+ npm install
517
+
518
+ # Start dev server (Next.js component playground)
519
+ npm run dev
520
+
521
+ # Build the library (ESM + CJS + types)
522
+ npm run build
523
+
524
+ # Build the Next.js showcase app
525
+ npm run build:next
526
+ ```
527
+
528
+ ### Updating design tokens
529
+
530
+ Design tokens are managed in Figma and exported as CSS variables. To update:
531
+
532
+ 1. Update the CSS custom properties in `app/globals.css` (playground) and `src/styles.css` (published package)
533
+ 2. Update `guides/rules/design-system-consuming-project.mdc` to reflect any token renames
534
+ 3. Update this README's token tables
535
+
536
+ ---
537
+
538
+ ## Tech stack
539
+
540
+ - **React 19** + **TypeScript**
541
+ - **Tailwind CSS v4** — CSS-first configuration
542
+ - **shadcn/ui** (New York style) — base component primitives
543
+ - **Radix UI** — accessible headless primitives
544
+ - **Figma** — source of truth for design tokens