@trading-game/design-intelligence-layer 0.11.1 → 0.12.1
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/README.md +15 -1
- package/dist/index.cjs +136 -89
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -16
- package/dist/index.d.ts +28 -16
- package/dist/index.js +135 -89
- package/dist/index.js.map +1 -1
- package/guides/design-system-guide/trading-game-ds-guide.md +45 -8
- package/package.json +1 -1
- package/src/styles.css +8 -0
|
@@ -135,12 +135,14 @@ import { Button, Card, Badge } from "@trading-game/design-intelligence-layer"
|
|
|
135
135
|
|
|
136
136
|
### 2.3 — Semantic (Trading Status)
|
|
137
137
|
|
|
138
|
-
| CSS Variable
|
|
139
|
-
|
|
|
140
|
-
| `--semantic-win`
|
|
141
|
-
| `--semantic-loss`
|
|
142
|
-
| `--semantic-warning`
|
|
143
|
-
| `--semantic-info`
|
|
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
|
+
| `--semantic-credit` | `bg-semantic-credit` | Credit / bonus badge background (`#F9840F` amber-orange) |
|
|
145
|
+
| `--semantic-credit-text` | `text-semantic-credit-text` | Credit / bonus badge foreground (`#713813` dark amber) |
|
|
144
146
|
|
|
145
147
|
> 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
148
|
|
|
@@ -273,6 +275,7 @@ import { Button, Card, Badge } from "@trading-game/design-intelligence-layer"
|
|
|
273
275
|
| Show WIN / profit / positive | `text-semantic-win` | Primary blue for profit |
|
|
274
276
|
| Show LOSS / negative | `text-semantic-loss` | Any non-token red |
|
|
275
277
|
| Show WARNING / caution | `text-semantic-warning` | Raw orange hex or primary tint |
|
|
278
|
+
| Show a credit / bonus badge | `<Badge variant="fill-credit">` (uses `bg-semantic-credit` + `text-semantic-credit-text`) | Hardcoded amber hex values |
|
|
276
279
|
| Color a tab container background | `bg-tabs` | `bg-subtle` for tabs |
|
|
277
280
|
| Color an active/selected tab | `bg-tabs-active` | `bg-prominent` for active tab |
|
|
278
281
|
| Color a page background | `bg-prominent` | `bg-white` directly |
|
|
@@ -553,7 +556,8 @@ import { Dialog, DialogTrigger, DialogContent, DialogHeader, DialogTitle, Dialog
|
|
|
553
556
|
| Table | [composed] | TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption |
|
|
554
557
|
| Tabs | [composed] | TabsList (`variant`: default/line, `size`: sm/md/lg), TabsTrigger (`iconPosition`: inline/top), TabsContent. Root accepts `orientation`: horizontal/vertical. |
|
|
555
558
|
| Textarea | [simple] | — |
|
|
556
|
-
| TicketCard | [composed] | — (`icon`, `label`, `value`, `currency`, `stubLabel`, `onStubClick`, `stubDisabled`, `
|
|
559
|
+
| TicketCard | [composed] | — (`icon`, `label`, `value`, `currency`, `stubLabel`, `onStubClick`, `stubDisabled`, `compact`) |
|
|
560
|
+
| CreditTicketCard | [composed] | — (`icon`, `label`, `value`, `currency`, `stubLabel`, `onStubClick`, `stubDisabled`, `creditAmount`, `creditCurrency`, `compact`) — use when a credit badge must appear below the value |
|
|
557
561
|
| Toggle | [simple] | — |
|
|
558
562
|
| ToggleGroup | [composed] | ToggleGroupItem |
|
|
559
563
|
| Tooltip | [composed] | TooltipTrigger, TooltipContent, TooltipProvider |
|
|
@@ -582,7 +586,9 @@ These are styling behaviors you can't discover from TypeScript types alone:
|
|
|
582
586
|
| Slider | Thumb: square `rounded-[4px]`, `bg-primary`. Track range: `bg-slider-range` |
|
|
583
587
|
| Dialog/Sheet | Footer buttons should use `size="md"`. Overlay: `bg-overlay` |
|
|
584
588
|
| Menubar | Hover: `bg-primary/[0.08]`. Open state: `bg-primary/10` |
|
|
585
|
-
|
|
|
589
|
+
| Badge | Variants: `default` (solid blue), `default-success`, `default-fail`; `fill` (blue tint), `fill-success`, `fill-fail`, `fill-warning`; `fill-credit` (amber-orange tint — `bg-semantic-credit/16` bg + `text-semantic-credit-text` foreground — use for credit/bonus labels, always pair with a `TicketPlus` icon); `outline`; `ghost`, `ghost-success`, `ghost-fail`. Base class no longer applies `tracking-wide` — letter spacing is default. |
|
|
590
|
+
| TicketCard | **Icon:** pass any `ReactNode` via `icon`. Icon container: `size-10` rounded-full, `border-2 border-primary`, `text-primary`. **Labels:** `label` (above value) and `stubLabel` (stub button) render in sentence case — do NOT apply `uppercase` or `tracking-widest`. Stub: `w-[100px]` `bg-primary` button, `text-on-prominent-static-inverse`, shimmer sweep animation. Disabled stub: `opacity-50`, `cursor-not-allowed`. Perforation notches sit outside the card box — do NOT put `overflow-hidden` on the card wrapper. **`compact`** (default `false`): `true` = mobile layout — reduces left-content horizontal padding from `px-4 gap-4` to `px-2 gap-2`. **For credit use cases:** use `CreditTicketCard` instead — it renders a `<Badge variant="fill-credit">` inline below the value. |
|
|
591
|
+
| CreditTicketCard | Same visual shell as `TicketCard` (perforation notches, tear-line, shimmer stub). The card height is **variable** (grows with content via `py-4`) rather than fixed at `h-20`. Credit is displayed as an inline `<Badge variant="fill-credit" size="sm">` with a `TicketPlus` icon: *"Credit: {creditAmount} {creditCurrency}"*. Tokens used: `bg-subtle`, `bg-primary`, `bg-primary-hover`, `text-on-prominent-static-inverse`, `bg-semantic-credit/16`, `text-semantic-credit-text`. Supports `compact` prop for mobile layout (same padding reduction as `TicketCard`). |
|
|
586
592
|
| Toggle | Pressed: `bg-primary/10` + `border-primary` + `text-primary` |
|
|
587
593
|
| Calendar | Selected: `bg-secondary-hover` + `text-primary font-bold`. Today: primary dot below date |
|
|
588
594
|
|
|
@@ -627,6 +633,37 @@ Landing page hero sections in multiple layout types.
|
|
|
627
633
|
|
|
628
634
|
---
|
|
629
635
|
|
|
636
|
+
### Sheet Open Positions
|
|
637
|
+
|
|
638
|
+
A slide-in panel listing the user's open trading positions. Responsive — renders as a right-side `Sheet` on desktop and a bottom `Drawer` on mobile.
|
|
639
|
+
|
|
640
|
+
| State | Description |
|
|
641
|
+
|-------|-------------|
|
|
642
|
+
| Active | Scrollable list of open positions with direction, asset, stake, and P&L per row. Win/loss coloured with semantic tokens. Footer button links to transaction history. |
|
|
643
|
+
| Empty | Empty state with icon and "No trades yet." message in place of the list. |
|
|
644
|
+
|
|
645
|
+
**Components used:** `Sheet`, `Drawer`, `Item`, `ItemGroup`, `ItemContent`, `ItemTitle`, `ItemDescription`, `ItemActions`, `Empty`, `EmptyHeader`, `EmptyMedia`, `EmptyTitle`, `Button`, `NavigationButton`, `Separator`
|
|
646
|
+
|
|
647
|
+
**Tokens used:** `bg-prominent`, `border-border-subtle`, `text-semantic-win`, `text-semantic-loss`, `text-on-prominent`, `text-on-subtle`
|
|
648
|
+
|
|
649
|
+
---
|
|
650
|
+
|
|
651
|
+
### Header navigation
|
|
652
|
+
|
|
653
|
+
A product app top header bar. Not a landing page component — used inside the trading game itself.
|
|
654
|
+
|
|
655
|
+
| Region | Content |
|
|
656
|
+
|--------|---------|
|
|
657
|
+
| Left | `NavigationButton` (back arrow) |
|
|
658
|
+
| Centre | `Badge` (fill-warning "Demo" label) + account balance amount + currency label |
|
|
659
|
+
| Right | `NavigationButton` icons for history and sound toggle |
|
|
660
|
+
|
|
661
|
+
**Components used:** `NavigationButton`, `Badge`
|
|
662
|
+
|
|
663
|
+
**Tokens used:** `bg-prominent`, `border-border-subtle`, `text-on-prominent`, `text-on-subtle`
|
|
664
|
+
|
|
665
|
+
---
|
|
666
|
+
|
|
630
667
|
## 9 — Common Mistakes
|
|
631
668
|
|
|
632
669
|
| Mistake | Correct Approach |
|
package/package.json
CHANGED
package/src/styles.css
CHANGED
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
--color-semantic-win: var(--semantic-win);
|
|
49
49
|
--color-semantic-loss: var(--semantic-loss);
|
|
50
50
|
--color-semantic-warning: var(--semantic-warning);
|
|
51
|
+
--color-semantic-credit: var(--semantic-credit);
|
|
52
|
+
--color-semantic-credit-text: var(--semantic-credit-text);
|
|
51
53
|
--color-alert-info-text: var(--alert-info-text);
|
|
52
54
|
--color-alert-info-border: var(--alert-info-border);
|
|
53
55
|
--color-alert-error-text: var(--alert-error-text);
|
|
@@ -167,6 +169,8 @@
|
|
|
167
169
|
/* ── Amber ── */
|
|
168
170
|
--primitive-amber-500: oklch(0.74 0.18 72);
|
|
169
171
|
/* #ef9f00 — golden amber; ticket credit progress fill */
|
|
172
|
+
--primitive-amber-600: #F9840F;
|
|
173
|
+
/* #F9840F — warm orange-amber; credit badge background base */
|
|
170
174
|
--primitive-amber-800: oklch(0.40 0.10 52);
|
|
171
175
|
/* #713813 — dark amber/brown; ticket credit label text */
|
|
172
176
|
|
|
@@ -265,6 +269,10 @@
|
|
|
265
269
|
--semantic-info: var(--primitive-sky-600);
|
|
266
270
|
--semantic-error: var(--primitive-red-600);
|
|
267
271
|
--semantic-warning: var(--primitive-orange-500);
|
|
272
|
+
--semantic-credit: var(--primitive-amber-600);
|
|
273
|
+
/* #F9840F — credit badge background */
|
|
274
|
+
--semantic-credit-text: var(--primitive-amber-800);
|
|
275
|
+
/* #713813 — credit badge foreground */
|
|
268
276
|
--tabs: var(--primitive-mono-alpha-4);
|
|
269
277
|
--tabs-active: var(--primitive-mono-50);
|
|
270
278
|
|