@trading-game/design-intelligence-layer 0.8.5
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 +70 -0
- package/README.md +464 -0
- package/dist/index.cjs +6798 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +611 -0
- package/dist/index.d.ts +611 -0
- package/dist/index.js +6473 -0
- package/dist/index.js.map +1 -0
- package/docs/accessibility-standards/trading-game-accessibility-standards.md +101 -0
- package/docs/design-principles/trading-game-design-principles.md +97 -0
- package/docs/design-system-guide/trading-game-ds-guide.md +2193 -0
- package/docs/personas/trading-game-player-field-guide.md +213 -0
- package/docs/rules/design-system-consuming-project.mdc +208 -0
- package/docs/tone-of-voice/trading-game-tone-of-voice-and-campaign-brief.md +290 -0
- package/package.json +85 -0
- package/src/styles.css +398 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
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/docs/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/docs/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/docs/personas/trading-game-player-field-guide.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Tone of voice** — the creative foundation, campaign territories, and the mirror test for all player-facing copy:
|
|
27
|
+
```
|
|
28
|
+
node_modules/@trading-game/design-intelligence-layer/docs/tone-of-voice/trading-game-tone-of-voice-and-campaign-brief.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 tone of 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/docs/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/docs/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-background`, `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
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## Reference
|
|
64
|
+
|
|
65
|
+
- Full token + component reference: `node_modules/@trading-game/design-intelligence-layer/README.md`
|
|
66
|
+
- Design principles: `node_modules/@trading-game/design-intelligence-layer/docs/design-principles/trading-game-design-principles.md`
|
|
67
|
+
- Accessibility standards: `node_modules/@trading-game/design-intelligence-layer/docs/accessibility-standards/trading-game-accessibility-standards.md`
|
|
68
|
+
- Personas: `node_modules/@trading-game/design-intelligence-layer/docs/personas/trading-game-player-field-guide.md`
|
|
69
|
+
- Tone of voice: `node_modules/@trading-game/design-intelligence-layer/docs/tone-of-voice/trading-game-tone-of-voice-and-campaign-brief.md`
|
|
70
|
+
- Full agent rules: `node_modules/@trading-game/design-intelligence-layer/docs/rules/design-system-consuming-project.mdc`
|
package/README.md
ADDED
|
@@ -0,0 +1,464 @@
|
|
|
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, and typography synced from Figma
|
|
88
|
+
- **Typography classes** — heading scale (h1–xs) and body scale (lg–xs) ready to use
|
|
89
|
+
- **TypeScript** — full type definitions included
|
|
90
|
+
- **ESM + CJS** — works with any bundler
|
|
91
|
+
|
|
92
|
+
---
|
|
93
|
+
|
|
94
|
+
## Available components
|
|
95
|
+
|
|
96
|
+
| Component | Import |
|
|
97
|
+
|---|---|
|
|
98
|
+
| Accordion | `Accordion, AccordionItem, AccordionTrigger, AccordionContent` |
|
|
99
|
+
| Alert | `Alert, AlertTitle, AlertDescription` |
|
|
100
|
+
| Alert Dialog | `AlertDialog, AlertDialogTrigger, AlertDialogContent, ...` |
|
|
101
|
+
| Avatar | `Avatar, AvatarImage, AvatarFallback, AvatarBadge, AvatarGroup` |
|
|
102
|
+
| Badge | `Badge, badgeVariants` |
|
|
103
|
+
| Breadcrumb | `Breadcrumb, BreadcrumbList, BreadcrumbItem, ...` |
|
|
104
|
+
| Button | `Button, buttonVariants` |
|
|
105
|
+
| Calendar | `Calendar, CalendarDayButton` |
|
|
106
|
+
| Card | `Card, CardHeader, CardTitle, CardDescription, CardContent, CardFooter` |
|
|
107
|
+
| Carousel | `Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext` |
|
|
108
|
+
| Chart | `ChartContainer, ChartTooltip, ChartLegend, ChartStyle` |
|
|
109
|
+
| Checkbox | `Checkbox` |
|
|
110
|
+
| Collapsible | `Collapsible, CollapsibleTrigger, CollapsibleContent` |
|
|
111
|
+
| Combobox | `Combobox, ComboboxInput, ComboboxContent, ComboboxItem, ...` |
|
|
112
|
+
| Command | `Command, CommandDialog, CommandInput, CommandList, ...` |
|
|
113
|
+
| Context Menu | `ContextMenu, ContextMenuTrigger, ContextMenuContent, ...` |
|
|
114
|
+
| Dialog | `Dialog, DialogTrigger, DialogContent, DialogHeader, ...` |
|
|
115
|
+
| Drawer | `Drawer, DrawerTrigger, DrawerContent, DrawerHeader, ...` |
|
|
116
|
+
| Dropdown Menu | `DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, ...` |
|
|
117
|
+
| Empty State | `Empty, EmptyHeader, EmptyTitle, EmptyDescription, EmptyContent` |
|
|
118
|
+
| Field | `Field, FieldLabel, FieldDescription, FieldError, FieldGroup` |
|
|
119
|
+
| Form | `Form, FormItem, FormLabel, FormControl, FormField, FormMessage` |
|
|
120
|
+
| Hover Card | `HoverCard, HoverCardTrigger, HoverCardContent` |
|
|
121
|
+
| Input | `Input` |
|
|
122
|
+
| Input Group | `InputGroup, InputGroupAddon, InputGroupButton, InputGroupText` |
|
|
123
|
+
| Input OTP | `InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator` |
|
|
124
|
+
| Item | `Item, ItemMedia, ItemContent, ItemTitle, ItemDescription` |
|
|
125
|
+
| Kbd | `Kbd, KbdGroup` |
|
|
126
|
+
| Label | `Label` |
|
|
127
|
+
| Link | `Link` |
|
|
128
|
+
| Menubar | `Menubar, MenubarMenu, MenubarTrigger, MenubarContent, ...` |
|
|
129
|
+
| Native Select | `NativeSelect, NativeSelectOptGroup, NativeSelectOption` |
|
|
130
|
+
| Navigation Menu | `NavigationMenu, NavigationMenuList, NavigationMenuTrigger, ...` |
|
|
131
|
+
| Pagination | `Pagination, PaginationContent, PaginationLink, ...` |
|
|
132
|
+
| Popover | `Popover, PopoverTrigger, PopoverContent, PopoverAnchor` |
|
|
133
|
+
| Progress | `Progress` |
|
|
134
|
+
| Radio Group | `RadioGroup, RadioGroupItem` |
|
|
135
|
+
| Resizable | `ResizableHandle, ResizablePanel, ResizablePanelGroup` |
|
|
136
|
+
| Scroll Area | `ScrollArea, ScrollBar` |
|
|
137
|
+
| Select | `Select, SelectTrigger, SelectContent, SelectItem, ...` |
|
|
138
|
+
| Separator | `Separator` |
|
|
139
|
+
| Sheet | `Sheet, SheetTrigger, SheetContent, SheetHeader, ...` |
|
|
140
|
+
| Sidebar | `Sidebar, SidebarProvider, SidebarMenu, SidebarMenuItem, ...` |
|
|
141
|
+
| Skeleton | `Skeleton` |
|
|
142
|
+
| Slider | `Slider` |
|
|
143
|
+
| Spinner | `Spinner` |
|
|
144
|
+
| Switch | `Switch` |
|
|
145
|
+
| Table | `Table, TableHeader, TableBody, TableRow, TableHead, TableCell` |
|
|
146
|
+
| Tabs | `Tabs, TabsList, TabsTrigger, TabsContent` |
|
|
147
|
+
| Textarea | `Textarea` |
|
|
148
|
+
| Ticket Card | `TicketCard` |
|
|
149
|
+
| Toast | `Toaster` |
|
|
150
|
+
| Toggle | `Toggle, toggleVariants` |
|
|
151
|
+
| Toggle Group | `ToggleGroup, ToggleGroupItem` |
|
|
152
|
+
| Tooltip | `Tooltip, TooltipTrigger, TooltipContent, TooltipProvider` |
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Button variants and sizes
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
<Button variant="primary" /> // Blue filled (#2323FF) — main CTA
|
|
160
|
+
<Button variant="secondary" /> // Black outline — secondary actions
|
|
161
|
+
<Button variant="tertiary" /> // Text only, underline on hover — minimal
|
|
162
|
+
|
|
163
|
+
// Sizes
|
|
164
|
+
<Button size="lg" /> // 48px height (default)
|
|
165
|
+
<Button size="md" /> // 40px height
|
|
166
|
+
<Button size="sm" /> // 32px height
|
|
167
|
+
<Button size="xs" /> // 24px height
|
|
168
|
+
<Button size="icon-lg" /> // 48px square
|
|
169
|
+
<Button size="icon-md" /> // 40px square
|
|
170
|
+
<Button size="icon-sm" /> // 28px square
|
|
171
|
+
<Button size="icon-xs" /> // 24px square
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Badge variants
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
// Default (solid)
|
|
178
|
+
<Badge variant="default" /> // Blue (#2323FF)
|
|
179
|
+
<Badge variant="default-success" /> // Green
|
|
180
|
+
<Badge variant="default-fail" /> // Red
|
|
181
|
+
|
|
182
|
+
// Fill (tint background)
|
|
183
|
+
<Badge variant="fill" /> // Blue tint
|
|
184
|
+
<Badge variant="fill-success" /> // Green tint
|
|
185
|
+
<Badge variant="fill-fail" /> // Red tint
|
|
186
|
+
|
|
187
|
+
// Outline (black border, secondary-hover on hover)
|
|
188
|
+
<Badge variant="outline" />
|
|
189
|
+
|
|
190
|
+
// Ghost (transparent)
|
|
191
|
+
<Badge variant="ghost" />
|
|
192
|
+
<Badge variant="ghost-success" />
|
|
193
|
+
<Badge variant="ghost-fail" />
|
|
194
|
+
|
|
195
|
+
// Sizes
|
|
196
|
+
<Badge size="sm" /> // 24px height
|
|
197
|
+
<Badge size="md" /> // 32px height (default)
|
|
198
|
+
<Badge size="lg" /> // 40px height
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Alert variants
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
<Alert variant="info" /> // blue — informational (default)
|
|
205
|
+
<Alert variant="error" /> // red — error state
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
## Design tokens
|
|
211
|
+
|
|
212
|
+
All tokens are CSS custom properties, loaded automatically via `@trading-game/design-intelligence-layer/styles`.
|
|
213
|
+
|
|
214
|
+
### Background tokens
|
|
215
|
+
|
|
216
|
+
| Tailwind class | CSS variable | Value | Usage |
|
|
217
|
+
|---|---|---|---|
|
|
218
|
+
| `bg-background` | `--background` | `#FFFFFF` | Page background |
|
|
219
|
+
| `bg-card` | `--card` | `#FFFFFF` | Card/panel surface |
|
|
220
|
+
| `bg-popover` | `--popover` | `#FFFFFF` | Popover/dropdown surface |
|
|
221
|
+
| `bg-subtle` | `--subtle` | `#F5F5F5` | Subtle tinted surface |
|
|
222
|
+
| `bg-overlay` | `--overlay` | black 50% | Modal/dialog backdrop only |
|
|
223
|
+
| `bg-primary` | `--primary` | `#2323FF` | Brand blue — CTAs |
|
|
224
|
+
| `bg-primary-hover` | `--primary-hover` | `#0B0BD2` | Primary button hover (darker blue) |
|
|
225
|
+
| `bg-secondary-hover` | `--secondary-hover` | `#EEEEEE` | Outline/secondary hover (light grey) |
|
|
226
|
+
| `bg-semantic-win` | `--semantic-win` | green | Profit / positive state |
|
|
227
|
+
| `bg-semantic-loss` | `--semantic-loss` | red | Loss / negative state |
|
|
228
|
+
|
|
229
|
+
### Text tokens
|
|
230
|
+
|
|
231
|
+
| Tailwind class | Value | Usage |
|
|
232
|
+
|---|---|---|
|
|
233
|
+
| `text-on-prominent` | `#000000` | Primary text on light backgrounds |
|
|
234
|
+
| `text-on-prominent-static-inverse` | `#FFFFFF` | Always white — for text on dark/primary backgrounds |
|
|
235
|
+
| `text-on-subtle` | mid grey | Secondary / supporting text |
|
|
236
|
+
| `text-on-muted` | dark grey | Low-emphasis text |
|
|
237
|
+
| `text-primary` | `#2323FF` | Brand blue inline text |
|
|
238
|
+
| `text-semantic-win` | green | Profit / positive text |
|
|
239
|
+
| `text-semantic-loss` | red | Loss / negative text |
|
|
240
|
+
|
|
241
|
+
### Border & focus tokens
|
|
242
|
+
|
|
243
|
+
| Tailwind class | CSS variable | Value | Usage |
|
|
244
|
+
|---|---|---|---|
|
|
245
|
+
| `border-border-subtle` | `--border-subtle` | `#EEEEEE` | **Default** — cards, dividers, form borders |
|
|
246
|
+
| `border-border-prominent` | `--border-prominent` | `#000000` | Outline variant components (button, badge, toggle) |
|
|
247
|
+
| `border-border` | `--border` | `#EEEEEE` | @deprecated alias — prefer `border-border-subtle` |
|
|
248
|
+
| `border-input` | `--input` | `#EEEEEE` | Input field borders |
|
|
249
|
+
| `ring-ring` | `--ring` | `#2323FF` | Focus rings |
|
|
250
|
+
|
|
251
|
+
> ⚠️ **`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.**
|
|
252
|
+
|
|
253
|
+
### Other tokens
|
|
254
|
+
|
|
255
|
+
| Tailwind class | Value | Usage |
|
|
256
|
+
|---|---|---|
|
|
257
|
+
| `bg-slider-range` | blue 40% | Slider filled range |
|
|
258
|
+
| `rounded-lg` | `0.625rem` | Base border radius |
|
|
259
|
+
|
|
260
|
+
### Using opacity with tokens
|
|
261
|
+
|
|
262
|
+
Opacity on tokens is allowed and encouraged:
|
|
263
|
+
|
|
264
|
+
```
|
|
265
|
+
✅ bg-primary/20 → blue at 20% opacity
|
|
266
|
+
✅ border-border-subtle/50 → light grey border at 50% opacity
|
|
267
|
+
✅ ring-ring/10 → ring at 10% opacity
|
|
268
|
+
|
|
269
|
+
❌ bg-black/50 → NOT a token, use bg-overlay instead
|
|
270
|
+
❌ bg-white → NOT a token, use bg-background or bg-card
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
275
|
+
## Typography
|
|
276
|
+
|
|
277
|
+
The styles export includes pre-built typography classes using **Plus Jakarta Sans**.
|
|
278
|
+
|
|
279
|
+
### Heading scale (Semibold 600 · tracking 1.5px · uppercase)
|
|
280
|
+
|
|
281
|
+
| Class | Size / Line height |
|
|
282
|
+
|---|---|
|
|
283
|
+
| `heading-h1` | 72px / 72px |
|
|
284
|
+
| `heading-h2` | 64px / 64px |
|
|
285
|
+
| `heading-h3` | 48px / 48px |
|
|
286
|
+
| `heading-h4` | 40px / 40px |
|
|
287
|
+
| `heading-xs` | 24px / 24px |
|
|
288
|
+
|
|
289
|
+
### Body scale (Semibold 600)
|
|
290
|
+
|
|
291
|
+
| Class | Size / Line height |
|
|
292
|
+
|---|---|
|
|
293
|
+
| `body-lg` | 18px / 28px |
|
|
294
|
+
| `body-md` | 16px / 24px |
|
|
295
|
+
| `body-sm` | 12px / 16px |
|
|
296
|
+
| `body-xs` | 8px / 12px |
|
|
297
|
+
|
|
298
|
+
### Font utilities
|
|
299
|
+
|
|
300
|
+
| Tailwind class | Font |
|
|
301
|
+
|---|---|
|
|
302
|
+
| `font-display` | Plus Jakarta Sans — headings, display text |
|
|
303
|
+
| `font-body` or `font-sans` | Plus Jakarta Sans — body text |
|
|
304
|
+
|
|
305
|
+
---
|
|
306
|
+
|
|
307
|
+
## Upgrading the design system
|
|
308
|
+
|
|
309
|
+
When you bump `@trading-game/design-intelligence-layer` and run `npm install` (or `npm ci`):
|
|
310
|
+
|
|
311
|
+
| How you use the package | What happens |
|
|
312
|
+
|-------------------------|----------------|
|
|
313
|
+
| 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. |
|
|
314
|
+
| 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. |
|
|
315
|
+
|
|
316
|
+
**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.
|
|
317
|
+
|
|
318
|
+
**Cursor / AI agents:** The package ships agent rules at `node_modules/@trading-game/design-intelligence-layer/docs/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.
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
## AI Agent Setup
|
|
323
|
+
|
|
324
|
+
### All AI tools (Cursor, Windsurf, Claude Code, Copilot, and others)
|
|
325
|
+
|
|
326
|
+
The package ships an `AGENTS.md` file that most AI tools read automatically. After installing the package, copy it to your project root:
|
|
327
|
+
|
|
328
|
+
```bash
|
|
329
|
+
cp node_modules/@trading-game/design-intelligence-layer/AGENTS.md ./AGENTS.md
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
This tells any AI agent to:
|
|
333
|
+
1. Read the design principles before building any screen
|
|
334
|
+
2. Follow the component and token rules
|
|
335
|
+
3. Run the 7-point checklist before completing any view
|
|
336
|
+
|
|
337
|
+
**Design principles file** (bundled in the package):
|
|
338
|
+
```
|
|
339
|
+
node_modules/@trading-game/design-intelligence-layer/docs/design-principles/trading-game-design-principles.md
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Accessibility standards file** (bundled in the package):
|
|
343
|
+
```
|
|
344
|
+
node_modules/@trading-game/design-intelligence-layer/docs/accessibility-standards/trading-game-accessibility-standards.md
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Personas file** (bundled in the package):
|
|
348
|
+
```
|
|
349
|
+
node_modules/@trading-game/design-intelligence-layer/docs/personas/trading-game-player-field-guide.md
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
**Tone of voice file** (bundled in the package):
|
|
353
|
+
```
|
|
354
|
+
node_modules/@trading-game/design-intelligence-layer/docs/tone-of-voice/trading-game-tone-of-voice-and-campaign-brief.md
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
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 tone of voice to guide all player-facing copy.
|
|
358
|
+
|
|
359
|
+
### Cursor
|
|
360
|
+
|
|
361
|
+
Copy the included rule file into your project:
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
mkdir -p .cursor/rules
|
|
365
|
+
cp node_modules/@trading-game/design-intelligence-layer/docs/rules/design-system-consuming-project.mdc .cursor/rules/
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
Re-run this **`cp` after every design-system version bump** so your workspace rules stay in sync with the installed package.
|
|
369
|
+
|
|
370
|
+
### Claude Code
|
|
371
|
+
|
|
372
|
+
Add the following to your project's `CLAUDE.md`:
|
|
373
|
+
|
|
374
|
+
```markdown
|
|
375
|
+
## Design System
|
|
376
|
+
|
|
377
|
+
This project uses @trading-game/design-intelligence-layer. Before writing any UI:
|
|
378
|
+
1. Read node_modules/@trading-game/design-intelligence-layer/docs/design-principles/trading-game-design-principles.md — apply the 8 principles and run the 7-point checklist on every screen
|
|
379
|
+
2. Read node_modules/@trading-game/design-intelligence-layer/docs/accessibility-standards/trading-game-accessibility-standards.md — apply WCAG 2.1 AA standards and run the 9-point accessibility checklist on every screen
|
|
380
|
+
3. Read node_modules/@trading-game/design-intelligence-layer/docs/personas/trading-game-player-field-guide.md — understand the 3 player modes (Edge Seeker, System Runner, Public Predictor) that shape all copy and UX
|
|
381
|
+
4. Read node_modules/@trading-game/design-intelligence-layer/docs/tone-of-voice/trading-game-tone-of-voice-and-campaign-brief.md — apply the voice, campaign territories, and mirror test for all player-facing copy
|
|
382
|
+
5. Check if the component exists in the package — import it, don't re-implement
|
|
383
|
+
6. Use only design token classes (bg-background, text-on-prominent, border-border-subtle, etc.) — no hardcoded hex or raw Tailwind palette colors
|
|
384
|
+
7. Do not install lucide-react, tailwindcss, or other bundled dependencies separately
|
|
385
|
+
8. If no token exists for a value, ask before using a hardcoded value
|
|
386
|
+
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 docs/rules/design-system-consuming-project.mdc into .cursor/rules if using Cursor
|
|
387
|
+
|
|
388
|
+
See node_modules/@trading-game/design-intelligence-layer/docs/rules/design-system-consuming-project.mdc for full rules.
|
|
389
|
+
See node_modules/@trading-game/design-intelligence-layer/README.md for complete token and component reference.
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Common mistakes
|
|
395
|
+
|
|
396
|
+
| Wrong | Right | Why |
|
|
397
|
+
|---|---|---|
|
|
398
|
+
| `bg-gray-100` | `bg-subtle` | Raw Tailwind palette — use tokens |
|
|
399
|
+
| `bg-white` | `bg-background` or `bg-card` | Not a semantic token |
|
|
400
|
+
| `text-white` | `text-on-prominent-static-inverse` | Use the semantic inverse token |
|
|
401
|
+
| `text-black` | `text-on-prominent` | Not a semantic token |
|
|
402
|
+
| `bg-black/50` | `bg-overlay` | Overlay has its own token |
|
|
403
|
+
| `bg-[#2323FF]` | `bg-primary` | Hardcoded hex — use token |
|
|
404
|
+
| `border-border` | `border-border-subtle` | Old name — prefer the new explicit name |
|
|
405
|
+
| `bg-[var(--primary)]` | `bg-primary` | Raw CSS var — Tailwind v4 maps tokens directly |
|
|
406
|
+
| `hsl(var(--primary))` | `bg-primary` | Tailwind v3 syntax — not needed in v4 |
|
|
407
|
+
| Installing `lucide-react` | Already bundled | Icons are included in the package |
|
|
408
|
+
|
|
409
|
+
---
|
|
410
|
+
|
|
411
|
+
## Do NOT install separately
|
|
412
|
+
|
|
413
|
+
These are bundled with the package. Installing them separately can cause version conflicts:
|
|
414
|
+
|
|
415
|
+
- `lucide-react` — icon library
|
|
416
|
+
- `radix-ui` — headless primitives
|
|
417
|
+
- `class-variance-authority` — variant API
|
|
418
|
+
- `cmdk` — command palette
|
|
419
|
+
- `vaul` — drawer
|
|
420
|
+
- `sonner` — toast
|
|
421
|
+
- `recharts` — charts
|
|
422
|
+
- `react-day-picker` — calendar
|
|
423
|
+
- `embla-carousel-react` — carousel
|
|
424
|
+
- `react-resizable-panels` — resizable panels
|
|
425
|
+
|
|
426
|
+
---
|
|
427
|
+
|
|
428
|
+
## Development (contributors only)
|
|
429
|
+
|
|
430
|
+
```bash
|
|
431
|
+
# Clone
|
|
432
|
+
git clone https://github.com/trading-game/TG-design-system.git
|
|
433
|
+
cd TG-design-system
|
|
434
|
+
|
|
435
|
+
# Install dependencies
|
|
436
|
+
npm install
|
|
437
|
+
|
|
438
|
+
# Start dev server (Next.js component playground)
|
|
439
|
+
npm run dev
|
|
440
|
+
|
|
441
|
+
# Build the library (ESM + CJS + types)
|
|
442
|
+
npm run build
|
|
443
|
+
|
|
444
|
+
# Build the Next.js showcase app
|
|
445
|
+
npm run build:next
|
|
446
|
+
```
|
|
447
|
+
|
|
448
|
+
### Updating design tokens
|
|
449
|
+
|
|
450
|
+
Design tokens are managed in Figma and exported as CSS variables. To update:
|
|
451
|
+
|
|
452
|
+
1. Update the CSS custom properties in `app/globals.css` (playground) and `src/styles.css` (published package)
|
|
453
|
+
2. Update `docs/rules/design-system-consuming-project.mdc` to reflect any token renames
|
|
454
|
+
3. Update this README's token tables
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
458
|
+
## Tech stack
|
|
459
|
+
|
|
460
|
+
- **React 19** + **TypeScript**
|
|
461
|
+
- **Tailwind CSS v4** — CSS-first configuration
|
|
462
|
+
- **shadcn/ui** (New York style) — base component primitives
|
|
463
|
+
- **Radix UI** — accessible headless primitives
|
|
464
|
+
- **Figma** — source of truth for design tokens
|