sisyo 1.7.0 → 1.8.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/LICENSE +16 -16
- package/README.md +167 -166
- package/bin/known-hashes.json +6 -1
- package/bin/sisyo.js +285 -285
- package/package.json +30 -30
- package/templates/.claude/rules/agents-and-tests.md +32 -24
- package/templates/.claude/rules/docs.md +19 -19
- package/templates/.claude/skills/fastapi-best-practices/ASYNC-PATTERNS.md +121 -121
- package/templates/.claude/skills/fastapi-best-practices/DATABASE.md +153 -153
- package/templates/.claude/skills/fastapi-best-practices/DEPENDENCIES.md +140 -140
- package/templates/.claude/skills/fastapi-best-practices/PROJECT-STRUCTURE.md +90 -90
- package/templates/.claude/skills/fastapi-best-practices/PYDANTIC-GUIDE.md +155 -155
- package/templates/.claude/skills/fastapi-best-practices/SKILL.md +123 -123
- package/templates/.claude/skills/g6-style/SKILL.md +125 -125
- package/templates/.claude/skills/g6-style/references/checks.md +58 -58
- package/templates/.claude/skills/g6-style/references/imagery.md +103 -103
- package/templates/.claude/skills/g6-style/references/motion.md +121 -121
- package/templates/.claude/skills/g6-style/references/sections.md +263 -263
- package/templates/.claude/skills/g6-style/references/tokens.md +197 -197
- package/templates/.claude/skills/hindsight/SKILL.md +175 -175
- package/templates/.claude/skills/hoang-auth/SKILL.md +188 -0
- package/templates/.claude/skills/html-docs/SKILL.md +207 -207
- package/templates/.claude/skills/i18n-multilang/SKILL.md +153 -153
- package/templates/.claude/skills/i18n-multilang/assets/languages.json +47 -47
- package/templates/.claude/skills/i18n-multilang/assets/plural-vectors.json +46 -46
- package/templates/.claude/skills/i18n-multilang/assets/project/README.md +17 -17
- package/templates/.claude/skills/i18n-multilang/assets/project/gitattributes.txt +6 -6
- package/templates/.claude/skills/i18n-multilang/assets/project/gitignore.txt +4 -4
- package/templates/.claude/skills/i18n-multilang/assets/project/glossary.json +6 -6
- package/templates/.claude/skills/i18n-multilang/assets/project/i18n.config.json +22 -22
- package/templates/.claude/skills/i18n-multilang/assets/project/locales/__source__/common.json +10 -10
- package/templates/.claude/skills/i18n-multilang/assets/project/notes/common.json +5 -5
- package/templates/.claude/skills/i18n-multilang/assets/project/style.md +20 -20
- package/templates/.claude/skills/i18n-multilang/references/format.md +100 -100
- package/templates/.claude/skills/i18n-multilang/references/languages.md +97 -97
- package/templates/.claude/skills/i18n-multilang/references/layout-and-versioning.md +256 -256
- package/templates/.claude/skills/i18n-multilang/references/numbers.md +161 -161
- package/templates/.claude/skills/i18n-multilang/references/platform-unity.md +142 -142
- package/templates/.claude/skills/i18n-multilang/references/platform-web.md +107 -107
- package/templates/.claude/skills/i18n-multilang/references/translation.md +143 -143
- package/templates/.claude/skills/i18n-multilang/references/voice.md +271 -271
- package/templates/.claude/skills/i18n-multilang/scripts/i18n.py +1041 -1041
- package/templates/.claude/skills/i18n-multilang/scripts/numwords.py +1013 -1013
- package/templates/.claude/skills/i18n-multilang/scripts/voice.py +478 -478
- package/templates/.claude/skills/neon-game-ui-ux-skill/COMPONENTS.md +490 -490
- package/templates/.claude/skills/neon-game-ui-ux-skill/GAMIFICATION.md +246 -246
- package/templates/.claude/skills/neon-game-ui-ux-skill/ICONS.md +249 -249
- package/templates/.claude/skills/neon-game-ui-ux-skill/LAYOUT-NAV.md +362 -362
- package/templates/.claude/skills/neon-game-ui-ux-skill/MOTION-A11Y.md +168 -168
- package/templates/.claude/skills/neon-game-ui-ux-skill/SKILL.md +137 -137
- package/templates/.claude/skills/neon-game-ui-ux-skill/TOKENS.md +323 -323
- package/templates/.claude/skills/react-page-oriented/SKILL.md +407 -407
- package/templates/.claude/skills/react-page-oriented/triggers.md +12 -12
- package/templates/.claude/skills/terraform-best-practices/SKILL.md +341 -341
- package/templates/.claude/skills/typesafe-jev/SKILL.md +148 -148
- package/templates/.claude/skills/vibe-docs/SKILL.md +242 -242
- package/templates/SISYO.md +37 -37
- package/templates/docs/99_progress/features.md +7 -7
- package/templates/docs/99_progress/handoff.md +19 -19
- package/templates/docs/99_progress/todo.md +15 -15
- package/templates/docs/MAP.md +26 -26
|
@@ -1,490 +1,490 @@
|
|
|
1
|
-
# Components
|
|
2
|
-
|
|
3
|
-
One entry per shared component: anatomy, sizes, the look of each state, props worth having, accessibility, and the
|
|
4
|
-
implementation tricks that are easy to get wrong. Build each component in the project from its entry; the token and
|
|
5
|
-
class names are those of `TOKENS.md`. The stack assumed is React 18 + TypeScript + Tailwind 3 + `motion/react`; the
|
|
6
|
-
techniques (inset-shadow rings, transform-only motion, tone scopes) carry over to any stack.
|
|
7
|
-
|
|
8
|
-
Conventions shared by all of them:
|
|
9
|
-
|
|
10
|
-
- `tone` props take `lime | aqua | iris | flare | amber | ember | gold | coral | mono` and are applied with a
|
|
11
|
-
`.tone-*` scope (TOKENS.md §5).
|
|
12
|
-
- Class names are joined with a helper that only concatenates truthy strings. It does **not** resolve conflicting
|
|
13
|
-
Tailwind classes, so a `className` prop can add utilities but should not try to override one the component sets.
|
|
14
|
-
- A control that navigates takes a `to` prop and renders the router's link element instead of a `<button>`, with the
|
|
15
|
-
same classes.
|
|
16
|
-
- Every interactive element is >= 44x44 px to touch, even when it looks smaller: the visual is 36 px and a
|
|
17
|
-
pseudo-element widens the hit area (`relative after:absolute after:-inset-1 after:content-['']`).
|
|
18
|
-
- Transitions list their properties (`transition-[transform,box-shadow,background-color]`), 180 ms `ease-glide`, and
|
|
19
|
-
switch to 120 ms while pressed. Never `transition: all`.
|
|
20
|
-
|
|
21
|
-
## Icon
|
|
22
|
-
|
|
23
|
-
`<Icon name tone? size=24 glow? className? title? />`
|
|
24
|
-
|
|
25
|
-
- An inline `<svg viewBox="0 0 24 24" fill="none" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">`
|
|
26
|
-
that paints one registry entry layer by layer (the layer model, the gradients and how the registry is made:
|
|
27
|
-
`ICONS.md`).
|
|
28
|
-
- Without `tone` the registry's default tone is used. `tone="mono"` paints with `currentColor`: set the text colour on
|
|
29
|
-
a parent.
|
|
30
|
-
- `glow` adds `filter: drop-shadow(0 0 6px rgb(tone / .6))` and `overflow: visible`; in mono the shadow colour is
|
|
31
|
-
`color-mix(in srgb, currentColor 60%, transparent)`. **Active or celebration states only.**
|
|
32
|
-
- Without `title` the icon is decorative (`aria-hidden`, `focusable="false"`). With `title` it is `role="img"` with
|
|
33
|
-
that label. An icon that is the only content of a control gets its name from the control's `aria-label`, not from
|
|
34
|
-
`title`.
|
|
35
|
-
- Always `shrink-0`: in a flex row an SVG is the first thing to be squeezed.
|
|
36
|
-
|
|
37
|
-
## RoundButton
|
|
38
|
-
|
|
39
|
-
The signature control: a circular keycap with a neon ring.
|
|
40
|
-
|
|
41
|
-
| Prop | Values | Notes |
|
|
42
|
-
|---|---|---|
|
|
43
|
-
| `icon` | icon name | required |
|
|
44
|
-
| `size` | `sm` 36 px disc / 18 px icon, `md` 48 / 22 (default), `lg` 64 / 28, `xl` 88 / 36 | `sm` without a label gets the 44 px hit area |
|
|
45
|
-
| `variant` | `neon` (default), `primary`, `danger`, `ghost` | see below |
|
|
46
|
-
| `tone` | ring + icon tone for `neon` / `ghost` | default lime for `neon`, mono for `ghost`; `danger` forces coral |
|
|
47
|
-
| `label` | caption under the disc | uppercase display font, 12 px, `tracking .08em`, `ink-soft`; also the accessible name |
|
|
48
|
-
| `aria-label` | required when there is no `label` | log a development-only warning when both are missing |
|
|
49
|
-
| `active` | `true` = toggled on | primary look + pulsing halo; sets `aria-pressed`. Leave `undefined` for plain buttons, so no `aria-pressed` is emitted |
|
|
50
|
-
| `loading` | spinner ring | `.neon-sweep` around the disc, `aria-busy`, clicks ignored |
|
|
51
|
-
| `disabled`, `onClick`, `to`, `className` | | |
|
|
52
|
-
|
|
53
|
-
**Anatomy.** `button.group` (transparent, column, gap 6 px, holds the tone scope) > a relative wrapper > [halo, only
|
|
54
|
-
when `active`] + **disc** > `Icon`; then the caption. The disc, not the button, carries the shape and the motion, so
|
|
55
|
-
the caption is part of the tap target while only the disc moves.
|
|
56
|
-
|
|
57
|
-
**How the keycap is made.** There is no 3D transform: the depth is a hard, unblurred shadow.
|
|
58
|
-
|
|
59
|
-
- `neon` disc: `bg-surface-2` + a top highlight `radial-gradient(circle at 50% 30%, rgb(255 255 255/.10), transparent
|
|
60
|
-
60%)` + one box-shadow list: `inset 0 0 0 1.5px rgb(tone/.75)` (the ring), `0 0 16px rgb(tone/.28)` (the glow),
|
|
61
|
-
`0 4px 0 rgb(0 0 0/.45)` (the 4 px depth). Icon in the tone.
|
|
62
|
-
- `primary` / `active`: `bg-lime-face`, `text-on-neon`, `shadow-keycap-lime` (depth `#3F6E00`); the icon is mono, so
|
|
63
|
-
it is dark on lime.
|
|
64
|
-
- `ghost`: `bg-ink-title/[.06]`, no ring, no depth, `ink-soft` icon; hover `bg-ink-title/10` and `ink-title`. For
|
|
65
|
-
toolbars and close buttons.
|
|
66
|
-
- **Hover**: the disc moves up 1 px and scales to 1.04.
|
|
67
|
-
- **Press**: the disc translates **down 3 px** and its depth shadow shrinks **from 4 px to 1 px** in the same 120 ms
|
|
68
|
-
(`neon`: ring to .9, glow to `0 0 10px .3`; `primary`: glow to `0 0 16px .4`). 3 + 1 = 4: the face lands exactly
|
|
69
|
-
where its shadow ended, which reads as a key travelling into its base. Reset the hover scale to 1 while pressed.
|
|
70
|
-
`ghost` only moves 1 px.
|
|
71
|
-
- **Halo** (`active`): an absolutely placed sibling, 6 px larger than the disc on each side, `bg-neon-lime/40`,
|
|
72
|
-
`blur-md`, `motion-safe:animate-glow-pulse`. The pulse is on the halo; pulsing the disc itself would move the icon.
|
|
73
|
-
- **Focus**: the button has `focus-visible:outline-none` and the **disc** draws the outline through the group
|
|
74
|
-
(`group-focus-visible:outline`, 2 px aqua-ink, offset 3 px). Otherwise the ring wraps disc + caption as a rectangle.
|
|
75
|
-
- **Disabled**: `opacity-40 saturate-0`, `cursor-not-allowed`; no hover or press styles.
|
|
76
|
-
|
|
77
|
-
## NeonButton
|
|
78
|
-
|
|
79
|
-
Pill / rounded-rectangle text button.
|
|
80
|
-
|
|
81
|
-
| Prop | Values |
|
|
82
|
-
|---|---|
|
|
83
|
-
| `variant` | `cta` (default), `secondary`, `ghost`, `danger` |
|
|
84
|
-
| `size` | `sm`: 36 px high, radius 12, padding-x 14, 14 px text, 16 px icon, hit area widened to 44. `md`: 44 px, radius 16, padding-x 20, 15 px text, 18 px icon. `lg`: 52 px, radius 16, padding-x 28, 16 px text, 20 px icon |
|
|
85
|
-
| `icon`, `iconRight` | icon names |
|
|
86
|
-
| `loading` | a spinner replaces the left icon; the button keeps focus and ignores clicks; `aria-busy` |
|
|
87
|
-
| `fullWidth`, `disabled`, `type`, `onClick`, `to`, `className` | |
|
|
88
|
-
| `focusableWhenDisabled` | with `disabled`: stays focusable (`aria-disabled`), ignores clicks |
|
|
89
|
-
|
|
90
|
-
- Box: `relative inline-flex`, centred on both axes, `white-space: nowrap`, `user-select: none`. Gap between icon,
|
|
91
|
-
text and right icon: `sm` 6 px, `md` 8 px, `lg` 10 px.
|
|
92
|
-
- Typography: **only `cta` is uppercase display font.** `secondary`, `ghost` and `danger` use the text font,
|
|
93
|
-
semibold, in sentence case. The uppercase caption style of TOKENS.md §6 belongs to the round button, not to these.
|
|
94
|
-
- `cta`: `bg-cta` at `background-size: 200% 200%` drifting with `animate-flow`; uppercase bold display font, tracking
|
|
95
|
-
.06em, `text-on-neon`, mono icons. Shadow: `0 0 26px rgb(lime/.35), inset 0 1px 0 rgb(255 255 255/.6), 0 4px 0
|
|
96
|
-
#3F6E00`. Hover: up 1 px, glow `0 0 34px .5`, depth 5 px. Press: down 3 px, glow `0 0 18px`, depth 1 px.
|
|
97
|
-
**One per view.** Two flowing gradients compete and neither reads as primary.
|
|
98
|
-
- `secondary`: a dark keycap. `bg-surface-2`, `shadow-keycap`, `ring-1 ring-inset ring-line-strong`, lime-ink
|
|
99
|
-
semibold text, lime icon. Hover `bg-surface-3` + `ring-neon-lime/50`. Press: down 3 px + `shadow-pressed`.
|
|
100
|
-
- `ghost`: text only (`text-ink`, semibold), mono icon; hover `bg-ink-title/[.06]` + `ink-title`; pressed
|
|
101
|
-
`bg-ink-title/10`. No shadow and no movement.
|
|
102
|
-
- `danger`: `bg-neon-coral/10`, `ring-neon-coral/50`, coral-ink text and coral icon; hover tint 16 %; press 1 px.
|
|
103
|
-
- Spinner: a 16 px circle, `border-2 border-current`, right border transparent, `animate-spin`.
|
|
104
|
-
- Plain `disabled`: `pointer-events-none opacity-40 saturate-0`.
|
|
105
|
-
- `focusableWhenDisabled` exists because a button that becomes natively `disabled` while it has focus (Save, after
|
|
106
|
-
saving) drops keyboard focus to `<body>`. In that mode the button is not natively disabled; it gets `aria-disabled`
|
|
107
|
-
and its click handler calls `preventDefault` (which also blocks a form submit). The faded look is an **overlay**
|
|
108
|
-
(`before:` pseudo-element: `surface-1` at 60 % + `backdrop-saturate-0`, same radius) and the outer shadows are
|
|
109
|
-
removed. Opacity or a filter on the button itself would fade the focus ring too. `ghost` has no face to cover: there
|
|
110
|
-
the text colour drops to `ink` at 40 % instead of the overlay.
|
|
111
|
-
|
|
112
|
-
## GlowCard
|
|
113
|
-
|
|
114
|
-
`<GlowCard tone? interactive? padding="none|sm|md|lg" as="div|section|article" className?>`
|
|
115
|
-
|
|
116
|
-
- `.neon-card`; with `tone` it adds the tone scope + `.neon-glow` (the tinted top-right corner).
|
|
117
|
-
- Padding: `sm` 12 px; `md` 16 px, 20 px from `sm`; `lg` 20 px, 28 px from `sm`.
|
|
118
|
-
- `interactive`: hover lifts 2 px and strengthens the border to `line-strong`. The hover glow
|
|
119
|
-
(`0 0 28px rgb(var(--tone, var(--c-lime))/.18)`) lives on an `::after` that covers the card, with the card's radius
|
|
120
|
-
and `pointer-events: none`, and only that pseudo-element's **opacity** animates 0 → 1 in 200 ms. Animating
|
|
121
|
-
`box-shadow` on the card repaints it every frame.
|
|
122
|
-
- A card is a container, not a control: when the whole card navigates, wrap its content in one link and give that
|
|
123
|
-
link the focus ring.
|
|
124
|
-
|
|
125
|
-
## ProgressRing
|
|
126
|
-
|
|
127
|
-
`<ProgressRing value(0..1) size=34 stroke? tone="lime|aqua|iris|flare|gold|ember" label?>children</ProgressRing>`
|
|
128
|
-
|
|
129
|
-
- A wrapper of `size` x `size` px (inline grid, centred, `shrink-0`) holding an absolutely placed SVG and, above it,
|
|
130
|
-
the centre content.
|
|
131
|
-
- The SVG is rotated -90° so the arc starts at 12 o'clock, with `overflow: visible` for the glow. Two circles of
|
|
132
|
-
radius `(size - stroke) / 2`: the track (`stroke-surface-3`) and the arc.
|
|
133
|
-
- Default stroke by size: <= 40 px 3.5, <= 80 px 6, larger 10.
|
|
134
|
-
- **How the arc draws.** `stroke-dasharray = circumference` and `stroke-dashoffset = circumference * (1 - value)`,
|
|
135
|
-
round line caps, with a 600 ms `ease-glide` transition on `stroke-dashoffset`. The drawn value is state that starts
|
|
136
|
-
at **0** and is set to the real value inside a `requestAnimationFrame` after mount; without that first frame at 0
|
|
137
|
-
the browser has nothing to transition from and the ring appears already filled.
|
|
138
|
-
- The arc has `opacity: 0` while the drawn value is 0; otherwise the round cap shows as a dot at 12 o'clock.
|
|
139
|
-
- Arc paint: a 2-stop linear gradient (id from `useId()`) in the default `objectBoundingBox` units from `(0,0)` to
|
|
140
|
-
`(1,1)`, the diagonal of the arc's box; tone → neighbouring hue, taken from the **`-ink`
|
|
141
|
-
variables** so it survives the light theme: lime → aqua, aqua → info, iris → flare, flare → iris, gold → amber,
|
|
142
|
-
ember = amber → ember. Glow: `drop-shadow(0 0 max(2, stroke)px rgb(first stop / .45))`.
|
|
143
|
-
- Clamp the value to 0..1 and treat a non-finite value as 0.
|
|
144
|
-
- `children` is the centre content (a percentage, an icon). Without children a check in the ring's tone pops in
|
|
145
|
-
(`animate-pop-in`) at 100 %, sized `max(12, 0.42 * size)`.
|
|
146
|
-
- `role="progressbar"`, `aria-valuemin 0`, `aria-valuemax 100`, `aria-valuenow` (rounded percent), `aria-label` from
|
|
147
|
-
`label`. When the ring sits **inside a button** (the HUD button, the bottom bar's dial), wrap it in `aria-hidden`
|
|
148
|
-
and put the value in the button's accessible name: roles nested in a button are ignored.
|
|
149
|
-
|
|
150
|
-
## XpBar
|
|
151
|
-
|
|
152
|
-
`<XpBar current max level compact? className? />` where `current` = XP inside the level and `max` = the level's span
|
|
153
|
-
(GAMIFICATION.md §3). `max <= 0` means max level (the bar is full and the text says `MAX`).
|
|
154
|
-
|
|
155
|
-
- Default width 176 px. Header row above the bar: `LV 7` in `ink-soft` on the left, `120 / 500 XP` in lime-ink
|
|
156
|
-
`tabular-nums` on the right, display font 11 px semibold; the row is `aria-hidden`.
|
|
157
|
-
- Track: 10 px high, `rounded-full`, `bg-surface-3`, `overflow: hidden`, a 1 px inset white line at 6 %.
|
|
158
|
-
- **How the fill moves.** The fill is as wide as the track (`absolute inset-0`), painted `bg-comet` + `shadow-glow`,
|
|
159
|
-
and shifted with `transform: translateX((ratio - 1) * 100%)`: at 0 it is fully off to the left, at 1 it covers the
|
|
160
|
-
track. Transition on `transform`, 700 ms `ease-glide`. No width animation, so no layout work. Like the ring, the
|
|
161
|
-
shown ratio starts at 0 and is set in a `requestAnimationFrame`, so the bar slides in on mount.
|
|
162
|
-
- One sheen sweep per XP change: a narrow span (40 % wide, a transparent → white 35 % → transparent gradient,
|
|
163
|
-
`animate-shimmer-once`) inside the fill, **keyed by `current`**. A new key remounts it, which replays the
|
|
164
|
-
animation. It is not a loop.
|
|
165
|
-
- `role="progressbar"` with `aria-valuetext` "Level 7: 120 of 500 XP" (or "Level 7, max level").
|
|
166
|
-
- `compact`: a 2 px line with no header and no sheen, for the bottom edge of the mobile top bar; its `aria-label` is
|
|
167
|
-
the value text.
|
|
168
|
-
- Mark the bar's wrapper with `data-xp-target`: it is where the reward burst lands (the lookup: Reward system).
|
|
169
|
-
|
|
170
|
-
## LevelBadge
|
|
171
|
-
|
|
172
|
-
`<LevelBadge level size="sm|md|lg|xl" />`
|
|
173
|
-
|
|
174
|
-
| Size | Hexagon (w x h) | Number | Caption | Glow on the wrapper |
|
|
175
|
-
|---|---|---|---|---|
|
|
176
|
-
| `sm` | 28 x 32 | 12 px | none | `drop-shadow(0 0 5px rgb(flare/.4))` |
|
|
177
|
-
| `md` | 34 x 38 | 14 px | none | `0 0 8px flare/.45` |
|
|
178
|
-
| `lg` | 56 x 64 | 24 px | "LEVEL", 9 px, tracking .14em | `0 0 14px flare/.45` |
|
|
179
|
-
| `xl` | 140 x 160 | 60 px | "LEVEL", 12 px, tracking .2em | `0 0 32px iris/.6` |
|
|
180
|
-
|
|
181
|
-
Anatomy: a wrapper `span` (carries the `drop-shadow`, because `clip-path` would clip a box-shadow) > a `.hex` painted
|
|
182
|
-
`bg-iris` > a second `.hex` overlay with a glassy highlight
|
|
183
|
-
(`radial-gradient(circle at 30% 18%, rgb(255 255 255/.5), transparent 55%)`) > the number in bold display font,
|
|
184
|
-
`tabular-nums`, `text-on-neon`. `role="img"` with `aria-label="Level 7"`; the inner text is `aria-hidden`.
|
|
185
|
-
|
|
186
|
-
## StreakPill
|
|
187
|
-
|
|
188
|
-
`<StreakPill days state="done|at-risk|zero" />`
|
|
189
|
-
|
|
190
|
-
A 36 px high pill: `bg-surface-1`, `ring-1 ring-inset`, padding 8 px left / 12 px right, a 20 px flame icon, the day
|
|
191
|
-
count in bold display font 15 px `tabular-nums`.
|
|
192
|
-
|
|
193
|
-
| State | Ring | Flame | Number | Meaning |
|
|
194
|
-
|---|---|---|---|---|
|
|
195
|
-
| `done` | ember at 35 % + `0 0 14px rgb(ember/.18)` | ember, with `glow` | `ink-title` | Active today |
|
|
196
|
-
| `at-risk` | amber at 70 % | ember, `animate-float-3` (three floats, then rest) | amber-ink | Streak alive, nothing done today |
|
|
197
|
-
| `zero` | `line` | mono, 45 % opacity, greyscale | `ink-muted` | No streak |
|
|
198
|
-
|
|
199
|
-
`role="img"`, label "12-day streak, done today" / "..., practise today to keep it" / "..., no streak yet"; the digits
|
|
200
|
-
are `aria-hidden`. The three states differ by ring, motion and label text, not by colour alone.
|
|
201
|
-
|
|
202
|
-
## StatTile
|
|
203
|
-
|
|
204
|
-
`<StatTile label value unit? sub? tone icon />`
|
|
205
|
-
|
|
206
|
-
- `.neon-card .neon-glow` in the tone scope, padding 16 px (20 px from `sm`), column with 8 px gaps.
|
|
207
|
-
- Row 1: the uppercase muted label; top-right a 36 px icon tile (`rounded-xl`, tone face at 10 %, inset tone ring at
|
|
208
|
-
25 %, 20 px icon). Row 2: the value in the stat-value style, then `unit` in display font 16 px, tone-ink. Row 3:
|
|
209
|
-
`sub`, 12 px semibold, lime-ink.
|
|
210
|
-
- **Count-up.** A numeric value counts from the previously shown value to the new one in 600 ms with a cubic ease-out
|
|
211
|
-
(`1 - (1 - t)^3`), driven by `requestAnimationFrame`, rounded and formatted with thousands separators each frame.
|
|
212
|
-
- A `setTimeout` fallback at 700 ms cancels the frame loop and sets the final number. `requestAnimationFrame` can
|
|
213
|
-
stall (hidden tab, headless capture); without the fallback a tile can stay at 0 forever.
|
|
214
|
-
- Screen readers get the final value in an `sr-only` span; the animated digits are `aria-hidden`.
|
|
215
|
-
- With reduced motion the value is set instantly.
|
|
216
|
-
|
|
217
|
-
## ProcessPath
|
|
218
|
-
|
|
219
|
-
The daily path: 64 px round nodes joined by connectors, a chest at the end.
|
|
220
|
-
|
|
221
|
-
`<ProcessPath steps orientation="auto|horizontal|zigzag" />`, `step = { id, label, icon, state, progress?, to?,
|
|
222
|
-
reward?, hint? }`, `state = locked | current | in-progress | done | chest`.
|
|
223
|
-
|
|
224
|
-
**Node anatomy.** A 64 px box holds, in order: a slot **above** the node (one of: floating tag, reward chip, locked
|
|
225
|
-
tooltip), an optional halo or ring behind the node, the disc itself, and a label **below** (absolute, 96 px wide,
|
|
226
|
-
centred, uppercase display font 12 px, with a `surface-1` at 90 % background behind the text so it stays readable
|
|
227
|
-
over a connector). The slot and the label are absolutely positioned, so the node's box stays 64 px and the geometry
|
|
228
|
-
below holds.
|
|
229
|
-
|
|
230
|
-
| State | Disc | Extras |
|
|
231
|
-
|---|---|---|
|
|
232
|
-
| `locked` | `bg-surface-1`, inset 1.5 px `line-strong` ring, 28 px mono icon in `ink-faint`, a 24 px lock chip at the bottom-right corner | Rendered as a button with `aria-disabled="true"` (focusable, so the hint is reachable) and `aria-describedby` the tooltip; the tooltip (`hint`, default "Finish the previous step to unlock") fades in on hover **and** focus |
|
|
233
|
-
| `current` | `bg-surface-2`, `0 0 0 6px rgb(lime/.10), 0 0 28px rgb(lime/.35)`, `.neon-sweep`, 30 px icon with `glow` | A static blurred lime halo behind it; a lime "START" tag above (`animate-float-3`) |
|
|
234
|
-
| `in-progress` | the same face without the sweep | An 80 px `ProgressRing` (stroke 4) centred on the node; a "RESUME" tag |
|
|
235
|
-
| `done` | `bg-lime-face shadow-keycap-lime`, a 30 px mono check | A reward chip above (`+20 XP`, lime-ink on `surface-2`, lime ring 40 %) |
|
|
236
|
-
| `chest` not ready | `bg-surface-1`, inset 1.5 px gold ring at 35 %, chest icon at 50 % | Reward chip in gold-ink |
|
|
237
|
-
| `chest` **ready** (every earlier step is `done`) | `bg-surface-2`, inset 2 px gold ring at 85 % + `0 0 24px rgb(gold/.35)`, chest icon with `glow` | The node pops in (`animate-pop-in`) and 10 burst dots fly out once |
|
|
238
|
-
|
|
239
|
-
- The chest burst: 10 dots of 8 px placed at the node's centre, evenly spaced angles starting at the top, alternating
|
|
240
|
-
radius 62 / 44 px and colour lime / gold, each with its own `--dx` / `--dy` and `animate-xp-burst` delayed .25 s.
|
|
241
|
-
The positions are computed once as constants: random values in render would change on every re-render.
|
|
242
|
-
- A node with `to` is a link (hover up 2 px, press down 2 px, focus outline offset 6 px so it clears the sweep ring);
|
|
243
|
-
without `to` it is a `role="img"`.
|
|
244
|
-
- Accessible name of a node: `label, state description, reward` ("Quiz, up next", "Read, in progress, 40%",
|
|
245
|
-
"Chest, reward ready, +30 XP"). The visual label and the chips are `aria-hidden`.
|
|
246
|
-
- At most one loop per node: the current node's sweep ring is its only animation; its halo is static and its tag
|
|
247
|
-
floats three times and stops.
|
|
248
|
-
|
|
249
|
-
**Layout.** `auto` is horizontal from 640 px (a row needs about 480 px) and a zigzag below.
|
|
250
|
-
|
|
251
|
-
- Horizontal: an `<ol>` flex row with 48 px padding above (room for the tag) and 40 px below (room for the label).
|
|
252
|
-
Each item is node + connector; the connector is a 4 px high bar that takes the remaining width (`flex-1`, min 24 px,
|
|
253
|
-
6 px side margins). Pending = a dashed bar made with `repeating-linear-gradient(90deg, line-strong 0 8px,
|
|
254
|
-
transparent 8px 14px)`; done (the step **before** it is done) = lime → aqua gradient with `0 0 10px rgb(lime/.5)`.
|
|
255
|
-
- Zigzag: a column 240 px wide. Node `i` is centred at `x = 120 + [0, 44, 0, -44][i % 4]`,
|
|
256
|
-
`y = 44 + i * 136 + 32` (64 px node + 72 px gap = 136 px pitch; 44 px on top for the tag). Total height
|
|
257
|
-
`44 + count * 136 - 72 + 40`. Connectors are SVG lines between consecutive centres, drawn **under** the nodes:
|
|
258
|
-
4 px wide, round caps, dashed `8 8` in `line-strong` when pending, a lime → aqua gradient along the line with a
|
|
259
|
-
lime drop-shadow when done.
|
|
260
|
-
- A skeleton with the same geometry (64 px circles at the same positions, the same paddings and height) is shown
|
|
261
|
-
while the data loads, so the card does not change size when the steps arrive.
|
|
262
|
-
|
|
263
|
-
## QuestCard
|
|
264
|
-
|
|
265
|
-
`<QuestCard icon tone title progress goal reward state onClaim? />`, `state = active | complete | claimed | expired`.
|
|
266
|
-
|
|
267
|
-
- `.neon-card`, padding 16 px, a flex row with 12 px gaps, `overflow: hidden` (for the sheen).
|
|
268
|
-
- Left: a 40 x 44 hexagon tile. The outer `.hex` is painted in the tone at 40 % (the rim); two inner hexes inset
|
|
269
|
-
1.5 px paint `surface-1` and then the tone at 12 % (the face); a 22 px icon on top.
|
|
270
|
-
- Right, row 1: the title (14 px semibold, at most two lines) and the count `3/5` (display font, `tabular-nums`).
|
|
271
|
-
Row 2: a 6 px progress bar and, at its right, the reward chip or the action. The bar is the XP bar technique
|
|
272
|
-
(full-width fill + `translateX`, 700 ms): fill `rgb(var(--tone-ink))` with `0 0 8px rgb(tone/.55)`.
|
|
273
|
-
- Reward chip: 28 px high pill on `surface-2`, a 15 px icon + text in bold display font 12 px. A bolt and lime-ink
|
|
274
|
-
when the text matches `/xp/i`, otherwise a gem and aqua-ink.
|
|
275
|
-
- `complete`: the card switches to the **gold** tone scope, a gold border at 60 % and `0 0 24px rgb(gold/.18)`; the
|
|
276
|
-
chip turns gold. With `onClaim`, the chip is replaced by a gold **Claim** keycap (36 px high, radius 12, `bg-gold`,
|
|
277
|
-
uppercase bold 12 px, `text-on-neon`, depth `0 3px 0 #8A6200`, hit area widened) with a pulsing blurred gold halo
|
|
278
|
-
behind it, and a sheen (`bg-sheen`, two thirds of the card wide) loops across the card (`animate-shimmer`). Without
|
|
279
|
-
`onClaim` the sheen sweeps once.
|
|
280
|
-
- `claimed`: graphics (hex tile, bar) at 60 % opacity; the action becomes a lime check + "Claimed"; title `ink-soft`.
|
|
281
|
-
`expired`: graphics at 50 % + greyscale; "EXPIRED" in `ink-muted`; title `ink-muted`.
|
|
282
|
-
- Dimming applies to **graphics only**; text switches to a quieter ink instead of being faded, so it keeps AA
|
|
283
|
-
contrast.
|
|
284
|
-
- The bar is a `role="progressbar"` labelled by the title, with `aria-valuemax = goal`.
|
|
285
|
-
|
|
286
|
-
## AchievementBadge
|
|
287
|
-
|
|
288
|
-
`<AchievementBadge name description? tier="bronze|silver|gold|rare" state="earned|progress|locked|secret"
|
|
289
|
-
progress? icon? isNew? />`
|
|
290
|
-
|
|
291
|
-
- An 84 x 84 box holding a 56 x 64 hexagon medal; under it the name (12 px semibold), an optional description
|
|
292
|
-
(10 px, `ink-muted`), max width 144 px, centred.
|
|
293
|
-
- The medal is two hexagons: the outer one is the **rim**, an inner one inset 1.5 px is the **face**. On top: a glint
|
|
294
|
-
(`radial-gradient(circle at 32% 20%, rgb(255 255 255/.45), transparent 50%)`, clipped by its own `.hex`) and a
|
|
295
|
-
28 px mono icon.
|
|
296
|
-
|
|
297
|
-
| State | Rim | Face | Icon | Extras |
|
|
298
|
-
|---|---|---|---|---|
|
|
299
|
-
| `earned` | the tier gradient (the whole medal is the gradient) | | `text-on-neon` | Tier glow as a `drop-shadow` on a wrapper (10-12 px, tier colour at 30-50 %); a sheen crosses the medal on hover (translateX -100 % → 100 %, 700 ms) |
|
|
300
|
-
| `progress` | `line-strong` | tier gradient at 70 % opacity, greyscale | `text-on-neon` | An 84 px gold `ProgressRing` (stroke 3.5) around the medal; the percentage in gold-ink under the name |
|
|
301
|
-
| `locked` | `line-strong` | `surface-2` | `ink-muted` at 35 % | A 24 px lock chip at the bottom-right |
|
|
302
|
-
| `secret` | `line-strong` | `surface-2` | a bold "?" | The name reads `???`, no description |
|
|
303
|
-
|
|
304
|
-
- Tier faces: bronze and silver gradients (TOKENS.md §9), gold = `bg-gold`, rare = `bg-flare`.
|
|
305
|
-
- `isNew`: the box pops in and, when earned, a flare "NEW" ribbon sits at the top centre (9 px bold display font,
|
|
306
|
-
`text-on-neon`, `shadow-glow-flare`).
|
|
307
|
-
- The state is also in an `sr-only` line ("Earned", "In progress, 40%", "Locked", "Secret achievement").
|
|
308
|
-
|
|
309
|
-
## State chips (pattern)
|
|
310
|
-
|
|
311
|
-
LenS marks vocabulary words as new / known / mastered; the pattern generalises to any item with a small set of states.
|
|
312
|
-
|
|
313
|
-
- Chip: 32 px high pill, padding-x 12, 13 px medium text, `ring-1 ring-inset`. Neutral: `bg-surface-1 ring-line`.
|
|
314
|
-
"New": `bg-neon-flare/10 ring-neon-flare/55` + a tiny `NEW` tag (8 px bold display font, flare-ink). "Known",
|
|
315
|
-
accented: `bg-neon-aqua/[.08] ring-neon-aqua/45`. "Mastered": a 6 px gold dot with a gold glow before the text.
|
|
316
|
-
Selected: `bg-neon-lime text-on-neon shadow-glow`, semibold, markers hidden.
|
|
317
|
-
- Inline variant (inside running text): known = a dotted 1.5 px aqua-ink underline, offset 5 px; new = a flare tint
|
|
318
|
-
at 15 % + a 2 px flare underline drawn as an inset bottom shadow + a superscript `NEW`; mastered = a small gold dot
|
|
319
|
-
after the word.
|
|
320
|
-
- Every state has a non-colour marker (tag, dot, underline style) and an `sr-only` suffix (" (new word)").
|
|
321
|
-
- Clickable chips are buttons with `aria-pressed` and a widened hit area (4 px sideways, 6 px up and down).
|
|
322
|
-
- A check that pops in (`animate-pop-in`) marks "used" or "saved", with the meaning added to the `sr-only` suffix.
|
|
323
|
-
|
|
324
|
-
## Segmented
|
|
325
|
-
|
|
326
|
-
`<Segmented value options={[{value,label,icon?}]} onChange size="sm|md" aria-label|aria-labelledby aria-describedby? />`
|
|
327
|
-
|
|
328
|
-
- Container: `inline-grid auto-cols-fr grid-flow-col max-w-full`, `rounded-full`, `bg-surface-1`, padding 4 px, inset
|
|
329
|
-
`line` ring. Equal-width options that shrink together; labels truncate.
|
|
330
|
-
- Option heights: `md` 44 px on touch widths / 40 px from `sm`; `sm` 36 / 32 px with the hit area extended
|
|
331
|
-
vertically to 44 px.
|
|
332
|
-
- A real radio group: `role="radiogroup"` / `role="radio"` with `aria-checked`, roving `tabIndex` (only the selected
|
|
333
|
-
option, or the first when none is selected, is in the tab order), arrow keys + Home / End move focus **and
|
|
334
|
-
select**, wrapping at the ends.
|
|
335
|
-
- **The sliding pill.** The selected option renders one absolutely placed `motion.span` (`inset-0`, `rounded-full`,
|
|
336
|
-
`bg-surface-3`, shadow `inset 0 1px 0 rgb(255 255 255/.08), 0 0 0 1px rgb(lime/.4), 0 0 14px rgb(lime/.14)`) with a
|
|
337
|
-
`layoutId` that is unique per instance (`useId()`). When the selection changes, the library animates the pill from
|
|
338
|
-
the old option's box to the new one: spring, bounce 0.18, 350 ms. Label and icon sit above it (`relative`).
|
|
339
|
-
- Focus outline offset 0, because the container clips anything outside the option.
|
|
340
|
-
- Icons: 16 px (`sm`: 14), in their tone when selected, mono otherwise.
|
|
341
|
-
|
|
342
|
-
## Switch
|
|
343
|
-
|
|
344
|
-
`<Switch checked onChange label? disabled? aria-label? />`
|
|
345
|
-
|
|
346
|
-
- `role="switch"` + `aria-checked` on a button that is the **whole row** (label + track), min height 44 px.
|
|
347
|
-
- Track 44 x 26 px, `rounded-full`. On: `bg-neon-lime` + `0 0 14px rgb(lime/.45)`. Off: `bg-surface-3` + an inset
|
|
348
|
-
1 px `line-strong` ring.
|
|
349
|
-
- Knob 20 px, 3 px from the top-left; on = moved 18 px right and painted `on-neon` (dark on lime), off = `ink-soft`.
|
|
350
|
-
Transform transition 200 ms.
|
|
351
|
-
- The focus ring is drawn on the track (group focus), not around the row.
|
|
352
|
-
|
|
353
|
-
## Split control (pattern)
|
|
354
|
-
|
|
355
|
-
A "mix" setting (LenS: the share of new vs known items). A label row with a live text `80% known · 20% new` (each
|
|
356
|
-
part in its ink colour), a two-segment bar (10 px high, 4 px gap, aqua | flare, each segment's `flex-grow` set to its
|
|
357
|
-
percentage and transitioned over 300 ms; the smaller one has a 4 px minimum), and a `Segmented size="sm"` of the
|
|
358
|
-
allowed steps. The live text has `aria-live="polite"` and is the group's `aria-describedby`.
|
|
359
|
-
|
|
360
|
-
## Skeleton
|
|
361
|
-
|
|
362
|
-
`<Skeleton className circle? />`: a block of `surface-3` at 80 %, radius 12 px (or a circle), `overflow: hidden`,
|
|
363
|
-
with one sheen span inside (`bg-sheen`, two thirds wide, `animate-shimmer`). Size and shape come from `className`
|
|
364
|
-
(`"h-4 w-32"`, `"hex h-[38px] w-[34px]"`). `aria-hidden`; put `aria-busy` or a `role="status"` on the region instead.
|
|
365
|
-
A skeleton must have the **same box** as the loaded content: the layout never jumps.
|
|
366
|
-
|
|
367
|
-
## EmptyState
|
|
368
|
-
|
|
369
|
-
`<EmptyState title description? icon tone action? />`: centred column, padding 40 px vertical; a 56 x 64 hexagon tile
|
|
370
|
-
(rim tone at 35 %, face `surface-1` + tone at 10 %, 28 px icon), an `h3` (18 px semibold), one line of text
|
|
371
|
-
(`ink-soft`, max 384 px) and one action (usually a `NeonButton`). Say what will appear here and how to make it appear.
|
|
372
|
-
|
|
373
|
-
## Toast
|
|
374
|
-
|
|
375
|
-
`const { show, dismiss } = useToast()`; `show({ tone: 'success'|'error'|'info', title, description?, action?,
|
|
376
|
-
duration? })` returns an id. A provider at the root holds the list and renders the viewport in a portal on `<body>`.
|
|
377
|
-
|
|
378
|
-
- Card: `rounded-2xl`, `surface-2` at 95 % + `backdrop-blur-md`, inset tone ring at 40 %, shadow
|
|
379
|
-
`0 16px 40px rgb(0 0 0/.35), 0 0 24px rgb(tone/.14)`. Contents: a 32 px icon tile, title (14 px semibold, wraps
|
|
380
|
-
anywhere) + description (12 px), an optional action button (tone-ink text), a dismiss button.
|
|
381
|
-
- Tone map: success = lime + check, error = coral + warning, info = aqua + info.
|
|
382
|
-
- Up to 3 stacked (the oldest is dropped); 5 s, errors 8 s.
|
|
383
|
-
- **The countdown pauses while the toast is hovered or focused**: keep the remaining time in a ref; on pause clear
|
|
384
|
-
the timer and subtract the elapsed time (never below 1 s), on resume start a timer for what is left. On blur, only
|
|
385
|
-
resume when focus really left the toast (`relatedTarget` outside it).
|
|
386
|
-
- Position: top centre under the top bar on phones (`top: var(--shell-top) + 12px`, max width 448 px, newest on top);
|
|
387
|
-
from `md` bottom left of the content, 380 px wide, `bottom: var(--shell-bottom) + 20px`, and offset past the side
|
|
388
|
-
rail (`left: 24px`, `72px + 24px` from `lg`, `240px + 24px` from `xl`).
|
|
389
|
-
- Enter: opacity 0 → 1, y 8 → 0, scale .98 → 1 in 240 ms glide; exit 160 ms; `layout` so the stack closes ranks.
|
|
390
|
-
- Announcements go through **two always-mounted live regions** (`aria-live="polite"`, and `assertive` for errors)
|
|
391
|
-
that sit next to the stack in an `sr-only` box and receive the text `title + description`. A live region that is
|
|
392
|
-
mounted together with its text is often not announced, which is why the visual toast is not the live region.
|
|
393
|
-
- An `action` is a shortcut, never the only way to do something (a toast disappears). Using it also dismisses.
|
|
394
|
-
- Dismiss button and action are 44 px targets. The viewport is `pointer-events-none`; each card re-enables them.
|
|
395
|
-
|
|
396
|
-
## Reward system
|
|
397
|
-
|
|
398
|
-
`const { rewardXp } = useReward()`;
|
|
399
|
-
`rewardXp({ xp, anchor?, levelUp?: { level, unlocked? }, achievements?: [{ name }] })`. `anchor` is an element (its
|
|
400
|
-
centre is used) or a viewport point `{ x, y }`; default: the screen centre.
|
|
401
|
-
|
|
402
|
-
A provider at the root does four things:
|
|
403
|
-
|
|
404
|
-
1. **Merges** gains that arrive within **400 ms** into one: the first call opens the window and measures the anchor
|
|
405
|
-
**at once** (the element may be gone when the window closes); later calls add their XP, merge the level-up (the
|
|
406
|
-
higher level, the union of unlocks) and append achievements.
|
|
407
|
-
2. **XP burst**, when the window closes and XP > 0:
|
|
408
|
-
- 8 to 12 dots of 6 px at the anchor, each with a random `--dx` / `--dy` of ±40-70 px, every third one aqua, the
|
|
409
|
-
rest lime, using `animate-xp-burst`.
|
|
410
|
-
- A chip (`+N XP` with a 16 px bolt: pill on `surface-2` at 90 %, lime-ink bold display font 14 px, `nowrap`,
|
|
411
|
-
lime ring 50 %, `shadow-glow`; padding 4 px vertical, 6 px left, 10 px right, 4 px gap) that flies to the target
|
|
412
|
-
in **700 ms** with the glide easing.
|
|
413
|
-
- **Centring.** The anchor and the target are points. The chip's moving wrapper is `position: absolute` at
|
|
414
|
-
`left: 0; top: 0` of the fixed overlay and is animated with x / y transforms to those points; the chip inside it
|
|
415
|
-
is translated by -50 % / -50 %, so its **centre** sits on the animated point. Each dot is `position: absolute`
|
|
416
|
-
at `left: anchor.x; top: anchor.y` with a -3 px margin on the left and top (half its 6 px). Without these offsets
|
|
417
|
-
the chip lands half its width to the right of the XP bar and the dots burst from a point beside the tap.
|
|
418
|
-
- **How the chip finds the HUD.** It queries every `[data-xp-target]` in the document and takes the **first whose
|
|
419
|
-
bounding box has a non-zero size**: the desktop XP bar is `display: none` on phones and is skipped, and the 2 px
|
|
420
|
-
line on the mobile top bar is taken instead. If none is visible it falls back to a point near the top-right
|
|
421
|
-
corner (`x = viewport width - 72, y = 28`).
|
|
422
|
-
- **The flight path** is an arc, not a line: three keyframes (start, mid, end) for x and y, where the mid point is
|
|
423
|
-
the midpoint of the chord pushed sideways by 18 % of the chord's length along the perpendicular that points up
|
|
424
|
-
the screen, and never above y = 16. Scale .6 → 1.1 → .55; opacity 0 → 1 (at 12 %) → 1 (at 85 %) → 0.
|
|
425
|
-
- On landing the burst is removed and the target **pulses**: a 520 ms Web Animations `filter` animation with the
|
|
426
|
-
glide easing, `none` → `brightness(1.45) drop-shadow(0 0 8px lime/.8)` → `none` (skipped with reduced motion).
|
|
427
|
-
3. **Toast**, 2.5 s: visible for gains >= 50 XP or any achievement. Smaller gains render the text `+N XP` as
|
|
428
|
-
`sr-only` in the same `aria-live="polite"` region: announced, not shown.
|
|
429
|
-
- Contents: a 28 px glowing icon (a lime bolt when there is XP, otherwise a gold trophy), then `+N XP` in lime-ink
|
|
430
|
-
bold display font 18 px and one "Achievement unlocked: <name>" line each (12 px, `ink-soft`, the name semibold in
|
|
431
|
-
`ink-title`).
|
|
432
|
-
- Card: a row with a 12 px gap, `rounded-2xl`, `surface-2` at 95 % + `backdrop-blur-md`, a 1 px lime ring at 40 %,
|
|
433
|
-
shadow `0 16px 40px rgb(0 0 0/.35), 0 0 24px rgb(lime/.2)`, padding 12 px vertical / 16 px horizontal, max width
|
|
434
|
-
384 px.
|
|
435
|
-
- Motion: enters with opacity 0 → 1, y 12 → 0, scale .96 → 1 in 240 ms glide; leaves upwards (y -8, scale .98).
|
|
436
|
-
- Position: the region is fixed and `pointer-events: none`; on phones bottom centre, 84 px + the bottom safe-area
|
|
437
|
-
inset above the bottom edge, with 16 px side padding; from `md` at `top: 80px; right: 24px`, right-aligned.
|
|
438
|
-
4. **Level-up modal**, opened when the chip lands (at once when there was no XP):
|
|
439
|
-
- Scrim `surface-void` at 80 % + `backdrop-blur-md`, fades 200 ms, scrolls vertically on a short screen,
|
|
440
|
-
`overflow-x: hidden` so the rays never widen the page. Clicking it closes.
|
|
441
|
-
- Rays behind the badge: a 540 px circle of `repeating-conic-gradient(rgb(iris/.34) 0 5deg, transparent 5deg
|
|
442
|
-
18deg)`, masked by `radial-gradient(circle, #000 16%, transparent 62%)`, rotating once per 20 s.
|
|
443
|
-
- `LevelBadge xl` entering with `animate-iris-open`; "LEVEL UP" (14 px display, tracking .3em, `ink-soft`); the
|
|
444
|
-
heading "LEVEL N" in `bg-flare-ink` gradient text, 48 px bold; an optional list of "Unlocked: ..." rows; one
|
|
445
|
-
full-width **Continue** CTA.
|
|
446
|
-
- A real dialog: `role="dialog" aria-modal="true"`, labelled by the heading, focus trapped, Continue focused, Esc
|
|
447
|
-
/ scrim click / Continue close it (LAYOUT-NAV.md §6).
|
|
448
|
-
|
|
449
|
-
Details:
|
|
450
|
-
|
|
451
|
-
- The burst overlay is `pointer-events-none fixed inset-0 overflow-hidden`, `aria-hidden`, portalled to `<body>`: a
|
|
452
|
-
celebration never blocks input.
|
|
453
|
-
- Reduced motion: no dots and no flight; the chip fades in 40 px above the source, holds and fades out over the same
|
|
454
|
-
700 ms. The badge appears without the rotation.
|
|
455
|
-
- z-order of the burst, the reward toast and the level-up modal: LAYOUT-NAV.md §1.
|
|
456
|
-
- All timers are tracked and cleared on unmount.
|
|
457
|
-
- Turning a server reward into these calls, and patching the HUD when the chip lands: GAMIFICATION.md §10.
|
|
458
|
-
|
|
459
|
-
## Hooks worth having
|
|
460
|
-
|
|
461
|
-
- **Theme** `{ theme, toggleTheme, setTheme }`. The DOM (`data-theme` on `<html>`) is the source of truth, read with
|
|
462
|
-
`useSyncExternalStore` and a `MutationObserver` on that attribute, so every consumer updates without a context
|
|
463
|
-
provider. Applying a theme sets the attribute, toggles the `dark` class, updates the `theme-color` meta
|
|
464
|
-
(`#05060A` / `#EEF1F8`) and writes `localStorage.theme` inside try/catch (storage can be blocked).
|
|
465
|
-
- **Modal focus** `(dialogRef, onClose, initialFocus?)`: LAYOUT-NAV.md §6.
|
|
466
|
-
- **Media query** `(query) → boolean`: `useSyncExternalStore` over `matchMedia`, with a `change` listener.
|
|
467
|
-
- **Dismiss** `(open, containerRef, onDismiss(reason))`: while open, a `pointerdown` outside the container or Escape
|
|
468
|
-
calls back with `'outside'` or `'escape'`; for non-modal popovers. Keep the callback in a ref so the listeners are
|
|
469
|
-
not re-bound on every render.
|
|
470
|
-
|
|
471
|
-
## Root providers
|
|
472
|
-
|
|
473
|
-
Wrap the app, outermost first: the data-cache provider, `MotionConfig reducedMotion="user"`, the router, the reward
|
|
474
|
-
provider, the toast provider. Both providers portal their overlays to `<body>`, outside `#root`, so they stay usable
|
|
475
|
-
while a dialog makes `#root` inert.
|
|
476
|
-
|
|
477
|
-
## The gallery page
|
|
478
|
-
|
|
479
|
-
Build a development-only route (`/dev/ui`, registered only in development builds) **before any product page**:
|
|
480
|
-
|
|
481
|
-
- Sections with anchors: Icons (every icon at 24 px + a tone strip), Buttons (every size x variant x state), Progress
|
|
482
|
-
(rings, XP bar, level badges, streak pills), Cards, Path (every node state, both layouts), Quests, Chips,
|
|
483
|
-
Achievements, Controls, Rewards (buttons that trigger a 10 XP and a 60 XP gain, a level-up, an achievement), Toasts.
|
|
484
|
-
- A sticky header with a theme toggle and a live `XpBar` marked `data-xp-target`, so the burst has somewhere to
|
|
485
|
-
land; credit the XP to that bar 700 ms after the trigger, when the chip arrives.
|
|
486
|
-
- Each example in a labelled `<figure>` with a mono caption naming the props.
|
|
487
|
-
- Exclude the gallery's folder from Tailwind's `content` in production builds, so gallery-only utilities never ship.
|
|
488
|
-
|
|
489
|
-
It is the fastest way to check both themes, 320 px width, keyboard focus and reduced motion for every component at
|
|
490
|
-
once, and it is where a new icon set is judged.
|
|
1
|
+
# Components
|
|
2
|
+
|
|
3
|
+
One entry per shared component: anatomy, sizes, the look of each state, props worth having, accessibility, and the
|
|
4
|
+
implementation tricks that are easy to get wrong. Build each component in the project from its entry; the token and
|
|
5
|
+
class names are those of `TOKENS.md`. The stack assumed is React 18 + TypeScript + Tailwind 3 + `motion/react`; the
|
|
6
|
+
techniques (inset-shadow rings, transform-only motion, tone scopes) carry over to any stack.
|
|
7
|
+
|
|
8
|
+
Conventions shared by all of them:
|
|
9
|
+
|
|
10
|
+
- `tone` props take `lime | aqua | iris | flare | amber | ember | gold | coral | mono` and are applied with a
|
|
11
|
+
`.tone-*` scope (TOKENS.md §5).
|
|
12
|
+
- Class names are joined with a helper that only concatenates truthy strings. It does **not** resolve conflicting
|
|
13
|
+
Tailwind classes, so a `className` prop can add utilities but should not try to override one the component sets.
|
|
14
|
+
- A control that navigates takes a `to` prop and renders the router's link element instead of a `<button>`, with the
|
|
15
|
+
same classes.
|
|
16
|
+
- Every interactive element is >= 44x44 px to touch, even when it looks smaller: the visual is 36 px and a
|
|
17
|
+
pseudo-element widens the hit area (`relative after:absolute after:-inset-1 after:content-['']`).
|
|
18
|
+
- Transitions list their properties (`transition-[transform,box-shadow,background-color]`), 180 ms `ease-glide`, and
|
|
19
|
+
switch to 120 ms while pressed. Never `transition: all`.
|
|
20
|
+
|
|
21
|
+
## Icon
|
|
22
|
+
|
|
23
|
+
`<Icon name tone? size=24 glow? className? title? />`
|
|
24
|
+
|
|
25
|
+
- An inline `<svg viewBox="0 0 24 24" fill="none" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">`
|
|
26
|
+
that paints one registry entry layer by layer (the layer model, the gradients and how the registry is made:
|
|
27
|
+
`ICONS.md`).
|
|
28
|
+
- Without `tone` the registry's default tone is used. `tone="mono"` paints with `currentColor`: set the text colour on
|
|
29
|
+
a parent.
|
|
30
|
+
- `glow` adds `filter: drop-shadow(0 0 6px rgb(tone / .6))` and `overflow: visible`; in mono the shadow colour is
|
|
31
|
+
`color-mix(in srgb, currentColor 60%, transparent)`. **Active or celebration states only.**
|
|
32
|
+
- Without `title` the icon is decorative (`aria-hidden`, `focusable="false"`). With `title` it is `role="img"` with
|
|
33
|
+
that label. An icon that is the only content of a control gets its name from the control's `aria-label`, not from
|
|
34
|
+
`title`.
|
|
35
|
+
- Always `shrink-0`: in a flex row an SVG is the first thing to be squeezed.
|
|
36
|
+
|
|
37
|
+
## RoundButton
|
|
38
|
+
|
|
39
|
+
The signature control: a circular keycap with a neon ring.
|
|
40
|
+
|
|
41
|
+
| Prop | Values | Notes |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| `icon` | icon name | required |
|
|
44
|
+
| `size` | `sm` 36 px disc / 18 px icon, `md` 48 / 22 (default), `lg` 64 / 28, `xl` 88 / 36 | `sm` without a label gets the 44 px hit area |
|
|
45
|
+
| `variant` | `neon` (default), `primary`, `danger`, `ghost` | see below |
|
|
46
|
+
| `tone` | ring + icon tone for `neon` / `ghost` | default lime for `neon`, mono for `ghost`; `danger` forces coral |
|
|
47
|
+
| `label` | caption under the disc | uppercase display font, 12 px, `tracking .08em`, `ink-soft`; also the accessible name |
|
|
48
|
+
| `aria-label` | required when there is no `label` | log a development-only warning when both are missing |
|
|
49
|
+
| `active` | `true` = toggled on | primary look + pulsing halo; sets `aria-pressed`. Leave `undefined` for plain buttons, so no `aria-pressed` is emitted |
|
|
50
|
+
| `loading` | spinner ring | `.neon-sweep` around the disc, `aria-busy`, clicks ignored |
|
|
51
|
+
| `disabled`, `onClick`, `to`, `className` | | |
|
|
52
|
+
|
|
53
|
+
**Anatomy.** `button.group` (transparent, column, gap 6 px, holds the tone scope) > a relative wrapper > [halo, only
|
|
54
|
+
when `active`] + **disc** > `Icon`; then the caption. The disc, not the button, carries the shape and the motion, so
|
|
55
|
+
the caption is part of the tap target while only the disc moves.
|
|
56
|
+
|
|
57
|
+
**How the keycap is made.** There is no 3D transform: the depth is a hard, unblurred shadow.
|
|
58
|
+
|
|
59
|
+
- `neon` disc: `bg-surface-2` + a top highlight `radial-gradient(circle at 50% 30%, rgb(255 255 255/.10), transparent
|
|
60
|
+
60%)` + one box-shadow list: `inset 0 0 0 1.5px rgb(tone/.75)` (the ring), `0 0 16px rgb(tone/.28)` (the glow),
|
|
61
|
+
`0 4px 0 rgb(0 0 0/.45)` (the 4 px depth). Icon in the tone.
|
|
62
|
+
- `primary` / `active`: `bg-lime-face`, `text-on-neon`, `shadow-keycap-lime` (depth `#3F6E00`); the icon is mono, so
|
|
63
|
+
it is dark on lime.
|
|
64
|
+
- `ghost`: `bg-ink-title/[.06]`, no ring, no depth, `ink-soft` icon; hover `bg-ink-title/10` and `ink-title`. For
|
|
65
|
+
toolbars and close buttons.
|
|
66
|
+
- **Hover**: the disc moves up 1 px and scales to 1.04.
|
|
67
|
+
- **Press**: the disc translates **down 3 px** and its depth shadow shrinks **from 4 px to 1 px** in the same 120 ms
|
|
68
|
+
(`neon`: ring to .9, glow to `0 0 10px .3`; `primary`: glow to `0 0 16px .4`). 3 + 1 = 4: the face lands exactly
|
|
69
|
+
where its shadow ended, which reads as a key travelling into its base. Reset the hover scale to 1 while pressed.
|
|
70
|
+
`ghost` only moves 1 px.
|
|
71
|
+
- **Halo** (`active`): an absolutely placed sibling, 6 px larger than the disc on each side, `bg-neon-lime/40`,
|
|
72
|
+
`blur-md`, `motion-safe:animate-glow-pulse`. The pulse is on the halo; pulsing the disc itself would move the icon.
|
|
73
|
+
- **Focus**: the button has `focus-visible:outline-none` and the **disc** draws the outline through the group
|
|
74
|
+
(`group-focus-visible:outline`, 2 px aqua-ink, offset 3 px). Otherwise the ring wraps disc + caption as a rectangle.
|
|
75
|
+
- **Disabled**: `opacity-40 saturate-0`, `cursor-not-allowed`; no hover or press styles.
|
|
76
|
+
|
|
77
|
+
## NeonButton
|
|
78
|
+
|
|
79
|
+
Pill / rounded-rectangle text button.
|
|
80
|
+
|
|
81
|
+
| Prop | Values |
|
|
82
|
+
|---|---|
|
|
83
|
+
| `variant` | `cta` (default), `secondary`, `ghost`, `danger` |
|
|
84
|
+
| `size` | `sm`: 36 px high, radius 12, padding-x 14, 14 px text, 16 px icon, hit area widened to 44. `md`: 44 px, radius 16, padding-x 20, 15 px text, 18 px icon. `lg`: 52 px, radius 16, padding-x 28, 16 px text, 20 px icon |
|
|
85
|
+
| `icon`, `iconRight` | icon names |
|
|
86
|
+
| `loading` | a spinner replaces the left icon; the button keeps focus and ignores clicks; `aria-busy` |
|
|
87
|
+
| `fullWidth`, `disabled`, `type`, `onClick`, `to`, `className` | |
|
|
88
|
+
| `focusableWhenDisabled` | with `disabled`: stays focusable (`aria-disabled`), ignores clicks |
|
|
89
|
+
|
|
90
|
+
- Box: `relative inline-flex`, centred on both axes, `white-space: nowrap`, `user-select: none`. Gap between icon,
|
|
91
|
+
text and right icon: `sm` 6 px, `md` 8 px, `lg` 10 px.
|
|
92
|
+
- Typography: **only `cta` is uppercase display font.** `secondary`, `ghost` and `danger` use the text font,
|
|
93
|
+
semibold, in sentence case. The uppercase caption style of TOKENS.md §6 belongs to the round button, not to these.
|
|
94
|
+
- `cta`: `bg-cta` at `background-size: 200% 200%` drifting with `animate-flow`; uppercase bold display font, tracking
|
|
95
|
+
.06em, `text-on-neon`, mono icons. Shadow: `0 0 26px rgb(lime/.35), inset 0 1px 0 rgb(255 255 255/.6), 0 4px 0
|
|
96
|
+
#3F6E00`. Hover: up 1 px, glow `0 0 34px .5`, depth 5 px. Press: down 3 px, glow `0 0 18px`, depth 1 px.
|
|
97
|
+
**One per view.** Two flowing gradients compete and neither reads as primary.
|
|
98
|
+
- `secondary`: a dark keycap. `bg-surface-2`, `shadow-keycap`, `ring-1 ring-inset ring-line-strong`, lime-ink
|
|
99
|
+
semibold text, lime icon. Hover `bg-surface-3` + `ring-neon-lime/50`. Press: down 3 px + `shadow-pressed`.
|
|
100
|
+
- `ghost`: text only (`text-ink`, semibold), mono icon; hover `bg-ink-title/[.06]` + `ink-title`; pressed
|
|
101
|
+
`bg-ink-title/10`. No shadow and no movement.
|
|
102
|
+
- `danger`: `bg-neon-coral/10`, `ring-neon-coral/50`, coral-ink text and coral icon; hover tint 16 %; press 1 px.
|
|
103
|
+
- Spinner: a 16 px circle, `border-2 border-current`, right border transparent, `animate-spin`.
|
|
104
|
+
- Plain `disabled`: `pointer-events-none opacity-40 saturate-0`.
|
|
105
|
+
- `focusableWhenDisabled` exists because a button that becomes natively `disabled` while it has focus (Save, after
|
|
106
|
+
saving) drops keyboard focus to `<body>`. In that mode the button is not natively disabled; it gets `aria-disabled`
|
|
107
|
+
and its click handler calls `preventDefault` (which also blocks a form submit). The faded look is an **overlay**
|
|
108
|
+
(`before:` pseudo-element: `surface-1` at 60 % + `backdrop-saturate-0`, same radius) and the outer shadows are
|
|
109
|
+
removed. Opacity or a filter on the button itself would fade the focus ring too. `ghost` has no face to cover: there
|
|
110
|
+
the text colour drops to `ink` at 40 % instead of the overlay.
|
|
111
|
+
|
|
112
|
+
## GlowCard
|
|
113
|
+
|
|
114
|
+
`<GlowCard tone? interactive? padding="none|sm|md|lg" as="div|section|article" className?>`
|
|
115
|
+
|
|
116
|
+
- `.neon-card`; with `tone` it adds the tone scope + `.neon-glow` (the tinted top-right corner).
|
|
117
|
+
- Padding: `sm` 12 px; `md` 16 px, 20 px from `sm`; `lg` 20 px, 28 px from `sm`.
|
|
118
|
+
- `interactive`: hover lifts 2 px and strengthens the border to `line-strong`. The hover glow
|
|
119
|
+
(`0 0 28px rgb(var(--tone, var(--c-lime))/.18)`) lives on an `::after` that covers the card, with the card's radius
|
|
120
|
+
and `pointer-events: none`, and only that pseudo-element's **opacity** animates 0 → 1 in 200 ms. Animating
|
|
121
|
+
`box-shadow` on the card repaints it every frame.
|
|
122
|
+
- A card is a container, not a control: when the whole card navigates, wrap its content in one link and give that
|
|
123
|
+
link the focus ring.
|
|
124
|
+
|
|
125
|
+
## ProgressRing
|
|
126
|
+
|
|
127
|
+
`<ProgressRing value(0..1) size=34 stroke? tone="lime|aqua|iris|flare|gold|ember" label?>children</ProgressRing>`
|
|
128
|
+
|
|
129
|
+
- A wrapper of `size` x `size` px (inline grid, centred, `shrink-0`) holding an absolutely placed SVG and, above it,
|
|
130
|
+
the centre content.
|
|
131
|
+
- The SVG is rotated -90° so the arc starts at 12 o'clock, with `overflow: visible` for the glow. Two circles of
|
|
132
|
+
radius `(size - stroke) / 2`: the track (`stroke-surface-3`) and the arc.
|
|
133
|
+
- Default stroke by size: <= 40 px 3.5, <= 80 px 6, larger 10.
|
|
134
|
+
- **How the arc draws.** `stroke-dasharray = circumference` and `stroke-dashoffset = circumference * (1 - value)`,
|
|
135
|
+
round line caps, with a 600 ms `ease-glide` transition on `stroke-dashoffset`. The drawn value is state that starts
|
|
136
|
+
at **0** and is set to the real value inside a `requestAnimationFrame` after mount; without that first frame at 0
|
|
137
|
+
the browser has nothing to transition from and the ring appears already filled.
|
|
138
|
+
- The arc has `opacity: 0` while the drawn value is 0; otherwise the round cap shows as a dot at 12 o'clock.
|
|
139
|
+
- Arc paint: a 2-stop linear gradient (id from `useId()`) in the default `objectBoundingBox` units from `(0,0)` to
|
|
140
|
+
`(1,1)`, the diagonal of the arc's box; tone → neighbouring hue, taken from the **`-ink`
|
|
141
|
+
variables** so it survives the light theme: lime → aqua, aqua → info, iris → flare, flare → iris, gold → amber,
|
|
142
|
+
ember = amber → ember. Glow: `drop-shadow(0 0 max(2, stroke)px rgb(first stop / .45))`.
|
|
143
|
+
- Clamp the value to 0..1 and treat a non-finite value as 0.
|
|
144
|
+
- `children` is the centre content (a percentage, an icon). Without children a check in the ring's tone pops in
|
|
145
|
+
(`animate-pop-in`) at 100 %, sized `max(12, 0.42 * size)`.
|
|
146
|
+
- `role="progressbar"`, `aria-valuemin 0`, `aria-valuemax 100`, `aria-valuenow` (rounded percent), `aria-label` from
|
|
147
|
+
`label`. When the ring sits **inside a button** (the HUD button, the bottom bar's dial), wrap it in `aria-hidden`
|
|
148
|
+
and put the value in the button's accessible name: roles nested in a button are ignored.
|
|
149
|
+
|
|
150
|
+
## XpBar
|
|
151
|
+
|
|
152
|
+
`<XpBar current max level compact? className? />` where `current` = XP inside the level and `max` = the level's span
|
|
153
|
+
(GAMIFICATION.md §3). `max <= 0` means max level (the bar is full and the text says `MAX`).
|
|
154
|
+
|
|
155
|
+
- Default width 176 px. Header row above the bar: `LV 7` in `ink-soft` on the left, `120 / 500 XP` in lime-ink
|
|
156
|
+
`tabular-nums` on the right, display font 11 px semibold; the row is `aria-hidden`.
|
|
157
|
+
- Track: 10 px high, `rounded-full`, `bg-surface-3`, `overflow: hidden`, a 1 px inset white line at 6 %.
|
|
158
|
+
- **How the fill moves.** The fill is as wide as the track (`absolute inset-0`), painted `bg-comet` + `shadow-glow`,
|
|
159
|
+
and shifted with `transform: translateX((ratio - 1) * 100%)`: at 0 it is fully off to the left, at 1 it covers the
|
|
160
|
+
track. Transition on `transform`, 700 ms `ease-glide`. No width animation, so no layout work. Like the ring, the
|
|
161
|
+
shown ratio starts at 0 and is set in a `requestAnimationFrame`, so the bar slides in on mount.
|
|
162
|
+
- One sheen sweep per XP change: a narrow span (40 % wide, a transparent → white 35 % → transparent gradient,
|
|
163
|
+
`animate-shimmer-once`) inside the fill, **keyed by `current`**. A new key remounts it, which replays the
|
|
164
|
+
animation. It is not a loop.
|
|
165
|
+
- `role="progressbar"` with `aria-valuetext` "Level 7: 120 of 500 XP" (or "Level 7, max level").
|
|
166
|
+
- `compact`: a 2 px line with no header and no sheen, for the bottom edge of the mobile top bar; its `aria-label` is
|
|
167
|
+
the value text.
|
|
168
|
+
- Mark the bar's wrapper with `data-xp-target`: it is where the reward burst lands (the lookup: Reward system).
|
|
169
|
+
|
|
170
|
+
## LevelBadge
|
|
171
|
+
|
|
172
|
+
`<LevelBadge level size="sm|md|lg|xl" />`
|
|
173
|
+
|
|
174
|
+
| Size | Hexagon (w x h) | Number | Caption | Glow on the wrapper |
|
|
175
|
+
|---|---|---|---|---|
|
|
176
|
+
| `sm` | 28 x 32 | 12 px | none | `drop-shadow(0 0 5px rgb(flare/.4))` |
|
|
177
|
+
| `md` | 34 x 38 | 14 px | none | `0 0 8px flare/.45` |
|
|
178
|
+
| `lg` | 56 x 64 | 24 px | "LEVEL", 9 px, tracking .14em | `0 0 14px flare/.45` |
|
|
179
|
+
| `xl` | 140 x 160 | 60 px | "LEVEL", 12 px, tracking .2em | `0 0 32px iris/.6` |
|
|
180
|
+
|
|
181
|
+
Anatomy: a wrapper `span` (carries the `drop-shadow`, because `clip-path` would clip a box-shadow) > a `.hex` painted
|
|
182
|
+
`bg-iris` > a second `.hex` overlay with a glassy highlight
|
|
183
|
+
(`radial-gradient(circle at 30% 18%, rgb(255 255 255/.5), transparent 55%)`) > the number in bold display font,
|
|
184
|
+
`tabular-nums`, `text-on-neon`. `role="img"` with `aria-label="Level 7"`; the inner text is `aria-hidden`.
|
|
185
|
+
|
|
186
|
+
## StreakPill
|
|
187
|
+
|
|
188
|
+
`<StreakPill days state="done|at-risk|zero" />`
|
|
189
|
+
|
|
190
|
+
A 36 px high pill: `bg-surface-1`, `ring-1 ring-inset`, padding 8 px left / 12 px right, a 20 px flame icon, the day
|
|
191
|
+
count in bold display font 15 px `tabular-nums`.
|
|
192
|
+
|
|
193
|
+
| State | Ring | Flame | Number | Meaning |
|
|
194
|
+
|---|---|---|---|---|
|
|
195
|
+
| `done` | ember at 35 % + `0 0 14px rgb(ember/.18)` | ember, with `glow` | `ink-title` | Active today |
|
|
196
|
+
| `at-risk` | amber at 70 % | ember, `animate-float-3` (three floats, then rest) | amber-ink | Streak alive, nothing done today |
|
|
197
|
+
| `zero` | `line` | mono, 45 % opacity, greyscale | `ink-muted` | No streak |
|
|
198
|
+
|
|
199
|
+
`role="img"`, label "12-day streak, done today" / "..., practise today to keep it" / "..., no streak yet"; the digits
|
|
200
|
+
are `aria-hidden`. The three states differ by ring, motion and label text, not by colour alone.
|
|
201
|
+
|
|
202
|
+
## StatTile
|
|
203
|
+
|
|
204
|
+
`<StatTile label value unit? sub? tone icon />`
|
|
205
|
+
|
|
206
|
+
- `.neon-card .neon-glow` in the tone scope, padding 16 px (20 px from `sm`), column with 8 px gaps.
|
|
207
|
+
- Row 1: the uppercase muted label; top-right a 36 px icon tile (`rounded-xl`, tone face at 10 %, inset tone ring at
|
|
208
|
+
25 %, 20 px icon). Row 2: the value in the stat-value style, then `unit` in display font 16 px, tone-ink. Row 3:
|
|
209
|
+
`sub`, 12 px semibold, lime-ink.
|
|
210
|
+
- **Count-up.** A numeric value counts from the previously shown value to the new one in 600 ms with a cubic ease-out
|
|
211
|
+
(`1 - (1 - t)^3`), driven by `requestAnimationFrame`, rounded and formatted with thousands separators each frame.
|
|
212
|
+
- A `setTimeout` fallback at 700 ms cancels the frame loop and sets the final number. `requestAnimationFrame` can
|
|
213
|
+
stall (hidden tab, headless capture); without the fallback a tile can stay at 0 forever.
|
|
214
|
+
- Screen readers get the final value in an `sr-only` span; the animated digits are `aria-hidden`.
|
|
215
|
+
- With reduced motion the value is set instantly.
|
|
216
|
+
|
|
217
|
+
## ProcessPath
|
|
218
|
+
|
|
219
|
+
The daily path: 64 px round nodes joined by connectors, a chest at the end.
|
|
220
|
+
|
|
221
|
+
`<ProcessPath steps orientation="auto|horizontal|zigzag" />`, `step = { id, label, icon, state, progress?, to?,
|
|
222
|
+
reward?, hint? }`, `state = locked | current | in-progress | done | chest`.
|
|
223
|
+
|
|
224
|
+
**Node anatomy.** A 64 px box holds, in order: a slot **above** the node (one of: floating tag, reward chip, locked
|
|
225
|
+
tooltip), an optional halo or ring behind the node, the disc itself, and a label **below** (absolute, 96 px wide,
|
|
226
|
+
centred, uppercase display font 12 px, with a `surface-1` at 90 % background behind the text so it stays readable
|
|
227
|
+
over a connector). The slot and the label are absolutely positioned, so the node's box stays 64 px and the geometry
|
|
228
|
+
below holds.
|
|
229
|
+
|
|
230
|
+
| State | Disc | Extras |
|
|
231
|
+
|---|---|---|
|
|
232
|
+
| `locked` | `bg-surface-1`, inset 1.5 px `line-strong` ring, 28 px mono icon in `ink-faint`, a 24 px lock chip at the bottom-right corner | Rendered as a button with `aria-disabled="true"` (focusable, so the hint is reachable) and `aria-describedby` the tooltip; the tooltip (`hint`, default "Finish the previous step to unlock") fades in on hover **and** focus |
|
|
233
|
+
| `current` | `bg-surface-2`, `0 0 0 6px rgb(lime/.10), 0 0 28px rgb(lime/.35)`, `.neon-sweep`, 30 px icon with `glow` | A static blurred lime halo behind it; a lime "START" tag above (`animate-float-3`) |
|
|
234
|
+
| `in-progress` | the same face without the sweep | An 80 px `ProgressRing` (stroke 4) centred on the node; a "RESUME" tag |
|
|
235
|
+
| `done` | `bg-lime-face shadow-keycap-lime`, a 30 px mono check | A reward chip above (`+20 XP`, lime-ink on `surface-2`, lime ring 40 %) |
|
|
236
|
+
| `chest` not ready | `bg-surface-1`, inset 1.5 px gold ring at 35 %, chest icon at 50 % | Reward chip in gold-ink |
|
|
237
|
+
| `chest` **ready** (every earlier step is `done`) | `bg-surface-2`, inset 2 px gold ring at 85 % + `0 0 24px rgb(gold/.35)`, chest icon with `glow` | The node pops in (`animate-pop-in`) and 10 burst dots fly out once |
|
|
238
|
+
|
|
239
|
+
- The chest burst: 10 dots of 8 px placed at the node's centre, evenly spaced angles starting at the top, alternating
|
|
240
|
+
radius 62 / 44 px and colour lime / gold, each with its own `--dx` / `--dy` and `animate-xp-burst` delayed .25 s.
|
|
241
|
+
The positions are computed once as constants: random values in render would change on every re-render.
|
|
242
|
+
- A node with `to` is a link (hover up 2 px, press down 2 px, focus outline offset 6 px so it clears the sweep ring);
|
|
243
|
+
without `to` it is a `role="img"`.
|
|
244
|
+
- Accessible name of a node: `label, state description, reward` ("Quiz, up next", "Read, in progress, 40%",
|
|
245
|
+
"Chest, reward ready, +30 XP"). The visual label and the chips are `aria-hidden`.
|
|
246
|
+
- At most one loop per node: the current node's sweep ring is its only animation; its halo is static and its tag
|
|
247
|
+
floats three times and stops.
|
|
248
|
+
|
|
249
|
+
**Layout.** `auto` is horizontal from 640 px (a row needs about 480 px) and a zigzag below.
|
|
250
|
+
|
|
251
|
+
- Horizontal: an `<ol>` flex row with 48 px padding above (room for the tag) and 40 px below (room for the label).
|
|
252
|
+
Each item is node + connector; the connector is a 4 px high bar that takes the remaining width (`flex-1`, min 24 px,
|
|
253
|
+
6 px side margins). Pending = a dashed bar made with `repeating-linear-gradient(90deg, line-strong 0 8px,
|
|
254
|
+
transparent 8px 14px)`; done (the step **before** it is done) = lime → aqua gradient with `0 0 10px rgb(lime/.5)`.
|
|
255
|
+
- Zigzag: a column 240 px wide. Node `i` is centred at `x = 120 + [0, 44, 0, -44][i % 4]`,
|
|
256
|
+
`y = 44 + i * 136 + 32` (64 px node + 72 px gap = 136 px pitch; 44 px on top for the tag). Total height
|
|
257
|
+
`44 + count * 136 - 72 + 40`. Connectors are SVG lines between consecutive centres, drawn **under** the nodes:
|
|
258
|
+
4 px wide, round caps, dashed `8 8` in `line-strong` when pending, a lime → aqua gradient along the line with a
|
|
259
|
+
lime drop-shadow when done.
|
|
260
|
+
- A skeleton with the same geometry (64 px circles at the same positions, the same paddings and height) is shown
|
|
261
|
+
while the data loads, so the card does not change size when the steps arrive.
|
|
262
|
+
|
|
263
|
+
## QuestCard
|
|
264
|
+
|
|
265
|
+
`<QuestCard icon tone title progress goal reward state onClaim? />`, `state = active | complete | claimed | expired`.
|
|
266
|
+
|
|
267
|
+
- `.neon-card`, padding 16 px, a flex row with 12 px gaps, `overflow: hidden` (for the sheen).
|
|
268
|
+
- Left: a 40 x 44 hexagon tile. The outer `.hex` is painted in the tone at 40 % (the rim); two inner hexes inset
|
|
269
|
+
1.5 px paint `surface-1` and then the tone at 12 % (the face); a 22 px icon on top.
|
|
270
|
+
- Right, row 1: the title (14 px semibold, at most two lines) and the count `3/5` (display font, `tabular-nums`).
|
|
271
|
+
Row 2: a 6 px progress bar and, at its right, the reward chip or the action. The bar is the XP bar technique
|
|
272
|
+
(full-width fill + `translateX`, 700 ms): fill `rgb(var(--tone-ink))` with `0 0 8px rgb(tone/.55)`.
|
|
273
|
+
- Reward chip: 28 px high pill on `surface-2`, a 15 px icon + text in bold display font 12 px. A bolt and lime-ink
|
|
274
|
+
when the text matches `/xp/i`, otherwise a gem and aqua-ink.
|
|
275
|
+
- `complete`: the card switches to the **gold** tone scope, a gold border at 60 % and `0 0 24px rgb(gold/.18)`; the
|
|
276
|
+
chip turns gold. With `onClaim`, the chip is replaced by a gold **Claim** keycap (36 px high, radius 12, `bg-gold`,
|
|
277
|
+
uppercase bold 12 px, `text-on-neon`, depth `0 3px 0 #8A6200`, hit area widened) with a pulsing blurred gold halo
|
|
278
|
+
behind it, and a sheen (`bg-sheen`, two thirds of the card wide) loops across the card (`animate-shimmer`). Without
|
|
279
|
+
`onClaim` the sheen sweeps once.
|
|
280
|
+
- `claimed`: graphics (hex tile, bar) at 60 % opacity; the action becomes a lime check + "Claimed"; title `ink-soft`.
|
|
281
|
+
`expired`: graphics at 50 % + greyscale; "EXPIRED" in `ink-muted`; title `ink-muted`.
|
|
282
|
+
- Dimming applies to **graphics only**; text switches to a quieter ink instead of being faded, so it keeps AA
|
|
283
|
+
contrast.
|
|
284
|
+
- The bar is a `role="progressbar"` labelled by the title, with `aria-valuemax = goal`.
|
|
285
|
+
|
|
286
|
+
## AchievementBadge
|
|
287
|
+
|
|
288
|
+
`<AchievementBadge name description? tier="bronze|silver|gold|rare" state="earned|progress|locked|secret"
|
|
289
|
+
progress? icon? isNew? />`
|
|
290
|
+
|
|
291
|
+
- An 84 x 84 box holding a 56 x 64 hexagon medal; under it the name (12 px semibold), an optional description
|
|
292
|
+
(10 px, `ink-muted`), max width 144 px, centred.
|
|
293
|
+
- The medal is two hexagons: the outer one is the **rim**, an inner one inset 1.5 px is the **face**. On top: a glint
|
|
294
|
+
(`radial-gradient(circle at 32% 20%, rgb(255 255 255/.45), transparent 50%)`, clipped by its own `.hex`) and a
|
|
295
|
+
28 px mono icon.
|
|
296
|
+
|
|
297
|
+
| State | Rim | Face | Icon | Extras |
|
|
298
|
+
|---|---|---|---|---|
|
|
299
|
+
| `earned` | the tier gradient (the whole medal is the gradient) | | `text-on-neon` | Tier glow as a `drop-shadow` on a wrapper (10-12 px, tier colour at 30-50 %); a sheen crosses the medal on hover (translateX -100 % → 100 %, 700 ms) |
|
|
300
|
+
| `progress` | `line-strong` | tier gradient at 70 % opacity, greyscale | `text-on-neon` | An 84 px gold `ProgressRing` (stroke 3.5) around the medal; the percentage in gold-ink under the name |
|
|
301
|
+
| `locked` | `line-strong` | `surface-2` | `ink-muted` at 35 % | A 24 px lock chip at the bottom-right |
|
|
302
|
+
| `secret` | `line-strong` | `surface-2` | a bold "?" | The name reads `???`, no description |
|
|
303
|
+
|
|
304
|
+
- Tier faces: bronze and silver gradients (TOKENS.md §9), gold = `bg-gold`, rare = `bg-flare`.
|
|
305
|
+
- `isNew`: the box pops in and, when earned, a flare "NEW" ribbon sits at the top centre (9 px bold display font,
|
|
306
|
+
`text-on-neon`, `shadow-glow-flare`).
|
|
307
|
+
- The state is also in an `sr-only` line ("Earned", "In progress, 40%", "Locked", "Secret achievement").
|
|
308
|
+
|
|
309
|
+
## State chips (pattern)
|
|
310
|
+
|
|
311
|
+
LenS marks vocabulary words as new / known / mastered; the pattern generalises to any item with a small set of states.
|
|
312
|
+
|
|
313
|
+
- Chip: 32 px high pill, padding-x 12, 13 px medium text, `ring-1 ring-inset`. Neutral: `bg-surface-1 ring-line`.
|
|
314
|
+
"New": `bg-neon-flare/10 ring-neon-flare/55` + a tiny `NEW` tag (8 px bold display font, flare-ink). "Known",
|
|
315
|
+
accented: `bg-neon-aqua/[.08] ring-neon-aqua/45`. "Mastered": a 6 px gold dot with a gold glow before the text.
|
|
316
|
+
Selected: `bg-neon-lime text-on-neon shadow-glow`, semibold, markers hidden.
|
|
317
|
+
- Inline variant (inside running text): known = a dotted 1.5 px aqua-ink underline, offset 5 px; new = a flare tint
|
|
318
|
+
at 15 % + a 2 px flare underline drawn as an inset bottom shadow + a superscript `NEW`; mastered = a small gold dot
|
|
319
|
+
after the word.
|
|
320
|
+
- Every state has a non-colour marker (tag, dot, underline style) and an `sr-only` suffix (" (new word)").
|
|
321
|
+
- Clickable chips are buttons with `aria-pressed` and a widened hit area (4 px sideways, 6 px up and down).
|
|
322
|
+
- A check that pops in (`animate-pop-in`) marks "used" or "saved", with the meaning added to the `sr-only` suffix.
|
|
323
|
+
|
|
324
|
+
## Segmented
|
|
325
|
+
|
|
326
|
+
`<Segmented value options={[{value,label,icon?}]} onChange size="sm|md" aria-label|aria-labelledby aria-describedby? />`
|
|
327
|
+
|
|
328
|
+
- Container: `inline-grid auto-cols-fr grid-flow-col max-w-full`, `rounded-full`, `bg-surface-1`, padding 4 px, inset
|
|
329
|
+
`line` ring. Equal-width options that shrink together; labels truncate.
|
|
330
|
+
- Option heights: `md` 44 px on touch widths / 40 px from `sm`; `sm` 36 / 32 px with the hit area extended
|
|
331
|
+
vertically to 44 px.
|
|
332
|
+
- A real radio group: `role="radiogroup"` / `role="radio"` with `aria-checked`, roving `tabIndex` (only the selected
|
|
333
|
+
option, or the first when none is selected, is in the tab order), arrow keys + Home / End move focus **and
|
|
334
|
+
select**, wrapping at the ends.
|
|
335
|
+
- **The sliding pill.** The selected option renders one absolutely placed `motion.span` (`inset-0`, `rounded-full`,
|
|
336
|
+
`bg-surface-3`, shadow `inset 0 1px 0 rgb(255 255 255/.08), 0 0 0 1px rgb(lime/.4), 0 0 14px rgb(lime/.14)`) with a
|
|
337
|
+
`layoutId` that is unique per instance (`useId()`). When the selection changes, the library animates the pill from
|
|
338
|
+
the old option's box to the new one: spring, bounce 0.18, 350 ms. Label and icon sit above it (`relative`).
|
|
339
|
+
- Focus outline offset 0, because the container clips anything outside the option.
|
|
340
|
+
- Icons: 16 px (`sm`: 14), in their tone when selected, mono otherwise.
|
|
341
|
+
|
|
342
|
+
## Switch
|
|
343
|
+
|
|
344
|
+
`<Switch checked onChange label? disabled? aria-label? />`
|
|
345
|
+
|
|
346
|
+
- `role="switch"` + `aria-checked` on a button that is the **whole row** (label + track), min height 44 px.
|
|
347
|
+
- Track 44 x 26 px, `rounded-full`. On: `bg-neon-lime` + `0 0 14px rgb(lime/.45)`. Off: `bg-surface-3` + an inset
|
|
348
|
+
1 px `line-strong` ring.
|
|
349
|
+
- Knob 20 px, 3 px from the top-left; on = moved 18 px right and painted `on-neon` (dark on lime), off = `ink-soft`.
|
|
350
|
+
Transform transition 200 ms.
|
|
351
|
+
- The focus ring is drawn on the track (group focus), not around the row.
|
|
352
|
+
|
|
353
|
+
## Split control (pattern)
|
|
354
|
+
|
|
355
|
+
A "mix" setting (LenS: the share of new vs known items). A label row with a live text `80% known · 20% new` (each
|
|
356
|
+
part in its ink colour), a two-segment bar (10 px high, 4 px gap, aqua | flare, each segment's `flex-grow` set to its
|
|
357
|
+
percentage and transitioned over 300 ms; the smaller one has a 4 px minimum), and a `Segmented size="sm"` of the
|
|
358
|
+
allowed steps. The live text has `aria-live="polite"` and is the group's `aria-describedby`.
|
|
359
|
+
|
|
360
|
+
## Skeleton
|
|
361
|
+
|
|
362
|
+
`<Skeleton className circle? />`: a block of `surface-3` at 80 %, radius 12 px (or a circle), `overflow: hidden`,
|
|
363
|
+
with one sheen span inside (`bg-sheen`, two thirds wide, `animate-shimmer`). Size and shape come from `className`
|
|
364
|
+
(`"h-4 w-32"`, `"hex h-[38px] w-[34px]"`). `aria-hidden`; put `aria-busy` or a `role="status"` on the region instead.
|
|
365
|
+
A skeleton must have the **same box** as the loaded content: the layout never jumps.
|
|
366
|
+
|
|
367
|
+
## EmptyState
|
|
368
|
+
|
|
369
|
+
`<EmptyState title description? icon tone action? />`: centred column, padding 40 px vertical; a 56 x 64 hexagon tile
|
|
370
|
+
(rim tone at 35 %, face `surface-1` + tone at 10 %, 28 px icon), an `h3` (18 px semibold), one line of text
|
|
371
|
+
(`ink-soft`, max 384 px) and one action (usually a `NeonButton`). Say what will appear here and how to make it appear.
|
|
372
|
+
|
|
373
|
+
## Toast
|
|
374
|
+
|
|
375
|
+
`const { show, dismiss } = useToast()`; `show({ tone: 'success'|'error'|'info', title, description?, action?,
|
|
376
|
+
duration? })` returns an id. A provider at the root holds the list and renders the viewport in a portal on `<body>`.
|
|
377
|
+
|
|
378
|
+
- Card: `rounded-2xl`, `surface-2` at 95 % + `backdrop-blur-md`, inset tone ring at 40 %, shadow
|
|
379
|
+
`0 16px 40px rgb(0 0 0/.35), 0 0 24px rgb(tone/.14)`. Contents: a 32 px icon tile, title (14 px semibold, wraps
|
|
380
|
+
anywhere) + description (12 px), an optional action button (tone-ink text), a dismiss button.
|
|
381
|
+
- Tone map: success = lime + check, error = coral + warning, info = aqua + info.
|
|
382
|
+
- Up to 3 stacked (the oldest is dropped); 5 s, errors 8 s.
|
|
383
|
+
- **The countdown pauses while the toast is hovered or focused**: keep the remaining time in a ref; on pause clear
|
|
384
|
+
the timer and subtract the elapsed time (never below 1 s), on resume start a timer for what is left. On blur, only
|
|
385
|
+
resume when focus really left the toast (`relatedTarget` outside it).
|
|
386
|
+
- Position: top centre under the top bar on phones (`top: var(--shell-top) + 12px`, max width 448 px, newest on top);
|
|
387
|
+
from `md` bottom left of the content, 380 px wide, `bottom: var(--shell-bottom) + 20px`, and offset past the side
|
|
388
|
+
rail (`left: 24px`, `72px + 24px` from `lg`, `240px + 24px` from `xl`).
|
|
389
|
+
- Enter: opacity 0 → 1, y 8 → 0, scale .98 → 1 in 240 ms glide; exit 160 ms; `layout` so the stack closes ranks.
|
|
390
|
+
- Announcements go through **two always-mounted live regions** (`aria-live="polite"`, and `assertive` for errors)
|
|
391
|
+
that sit next to the stack in an `sr-only` box and receive the text `title + description`. A live region that is
|
|
392
|
+
mounted together with its text is often not announced, which is why the visual toast is not the live region.
|
|
393
|
+
- An `action` is a shortcut, never the only way to do something (a toast disappears). Using it also dismisses.
|
|
394
|
+
- Dismiss button and action are 44 px targets. The viewport is `pointer-events-none`; each card re-enables them.
|
|
395
|
+
|
|
396
|
+
## Reward system
|
|
397
|
+
|
|
398
|
+
`const { rewardXp } = useReward()`;
|
|
399
|
+
`rewardXp({ xp, anchor?, levelUp?: { level, unlocked? }, achievements?: [{ name }] })`. `anchor` is an element (its
|
|
400
|
+
centre is used) or a viewport point `{ x, y }`; default: the screen centre.
|
|
401
|
+
|
|
402
|
+
A provider at the root does four things:
|
|
403
|
+
|
|
404
|
+
1. **Merges** gains that arrive within **400 ms** into one: the first call opens the window and measures the anchor
|
|
405
|
+
**at once** (the element may be gone when the window closes); later calls add their XP, merge the level-up (the
|
|
406
|
+
higher level, the union of unlocks) and append achievements.
|
|
407
|
+
2. **XP burst**, when the window closes and XP > 0:
|
|
408
|
+
- 8 to 12 dots of 6 px at the anchor, each with a random `--dx` / `--dy` of ±40-70 px, every third one aqua, the
|
|
409
|
+
rest lime, using `animate-xp-burst`.
|
|
410
|
+
- A chip (`+N XP` with a 16 px bolt: pill on `surface-2` at 90 %, lime-ink bold display font 14 px, `nowrap`,
|
|
411
|
+
lime ring 50 %, `shadow-glow`; padding 4 px vertical, 6 px left, 10 px right, 4 px gap) that flies to the target
|
|
412
|
+
in **700 ms** with the glide easing.
|
|
413
|
+
- **Centring.** The anchor and the target are points. The chip's moving wrapper is `position: absolute` at
|
|
414
|
+
`left: 0; top: 0` of the fixed overlay and is animated with x / y transforms to those points; the chip inside it
|
|
415
|
+
is translated by -50 % / -50 %, so its **centre** sits on the animated point. Each dot is `position: absolute`
|
|
416
|
+
at `left: anchor.x; top: anchor.y` with a -3 px margin on the left and top (half its 6 px). Without these offsets
|
|
417
|
+
the chip lands half its width to the right of the XP bar and the dots burst from a point beside the tap.
|
|
418
|
+
- **How the chip finds the HUD.** It queries every `[data-xp-target]` in the document and takes the **first whose
|
|
419
|
+
bounding box has a non-zero size**: the desktop XP bar is `display: none` on phones and is skipped, and the 2 px
|
|
420
|
+
line on the mobile top bar is taken instead. If none is visible it falls back to a point near the top-right
|
|
421
|
+
corner (`x = viewport width - 72, y = 28`).
|
|
422
|
+
- **The flight path** is an arc, not a line: three keyframes (start, mid, end) for x and y, where the mid point is
|
|
423
|
+
the midpoint of the chord pushed sideways by 18 % of the chord's length along the perpendicular that points up
|
|
424
|
+
the screen, and never above y = 16. Scale .6 → 1.1 → .55; opacity 0 → 1 (at 12 %) → 1 (at 85 %) → 0.
|
|
425
|
+
- On landing the burst is removed and the target **pulses**: a 520 ms Web Animations `filter` animation with the
|
|
426
|
+
glide easing, `none` → `brightness(1.45) drop-shadow(0 0 8px lime/.8)` → `none` (skipped with reduced motion).
|
|
427
|
+
3. **Toast**, 2.5 s: visible for gains >= 50 XP or any achievement. Smaller gains render the text `+N XP` as
|
|
428
|
+
`sr-only` in the same `aria-live="polite"` region: announced, not shown.
|
|
429
|
+
- Contents: a 28 px glowing icon (a lime bolt when there is XP, otherwise a gold trophy), then `+N XP` in lime-ink
|
|
430
|
+
bold display font 18 px and one "Achievement unlocked: <name>" line each (12 px, `ink-soft`, the name semibold in
|
|
431
|
+
`ink-title`).
|
|
432
|
+
- Card: a row with a 12 px gap, `rounded-2xl`, `surface-2` at 95 % + `backdrop-blur-md`, a 1 px lime ring at 40 %,
|
|
433
|
+
shadow `0 16px 40px rgb(0 0 0/.35), 0 0 24px rgb(lime/.2)`, padding 12 px vertical / 16 px horizontal, max width
|
|
434
|
+
384 px.
|
|
435
|
+
- Motion: enters with opacity 0 → 1, y 12 → 0, scale .96 → 1 in 240 ms glide; leaves upwards (y -8, scale .98).
|
|
436
|
+
- Position: the region is fixed and `pointer-events: none`; on phones bottom centre, 84 px + the bottom safe-area
|
|
437
|
+
inset above the bottom edge, with 16 px side padding; from `md` at `top: 80px; right: 24px`, right-aligned.
|
|
438
|
+
4. **Level-up modal**, opened when the chip lands (at once when there was no XP):
|
|
439
|
+
- Scrim `surface-void` at 80 % + `backdrop-blur-md`, fades 200 ms, scrolls vertically on a short screen,
|
|
440
|
+
`overflow-x: hidden` so the rays never widen the page. Clicking it closes.
|
|
441
|
+
- Rays behind the badge: a 540 px circle of `repeating-conic-gradient(rgb(iris/.34) 0 5deg, transparent 5deg
|
|
442
|
+
18deg)`, masked by `radial-gradient(circle, #000 16%, transparent 62%)`, rotating once per 20 s.
|
|
443
|
+
- `LevelBadge xl` entering with `animate-iris-open`; "LEVEL UP" (14 px display, tracking .3em, `ink-soft`); the
|
|
444
|
+
heading "LEVEL N" in `bg-flare-ink` gradient text, 48 px bold; an optional list of "Unlocked: ..." rows; one
|
|
445
|
+
full-width **Continue** CTA.
|
|
446
|
+
- A real dialog: `role="dialog" aria-modal="true"`, labelled by the heading, focus trapped, Continue focused, Esc
|
|
447
|
+
/ scrim click / Continue close it (LAYOUT-NAV.md §6).
|
|
448
|
+
|
|
449
|
+
Details:
|
|
450
|
+
|
|
451
|
+
- The burst overlay is `pointer-events-none fixed inset-0 overflow-hidden`, `aria-hidden`, portalled to `<body>`: a
|
|
452
|
+
celebration never blocks input.
|
|
453
|
+
- Reduced motion: no dots and no flight; the chip fades in 40 px above the source, holds and fades out over the same
|
|
454
|
+
700 ms. The badge appears without the rotation.
|
|
455
|
+
- z-order of the burst, the reward toast and the level-up modal: LAYOUT-NAV.md §1.
|
|
456
|
+
- All timers are tracked and cleared on unmount.
|
|
457
|
+
- Turning a server reward into these calls, and patching the HUD when the chip lands: GAMIFICATION.md §10.
|
|
458
|
+
|
|
459
|
+
## Hooks worth having
|
|
460
|
+
|
|
461
|
+
- **Theme** `{ theme, toggleTheme, setTheme }`. The DOM (`data-theme` on `<html>`) is the source of truth, read with
|
|
462
|
+
`useSyncExternalStore` and a `MutationObserver` on that attribute, so every consumer updates without a context
|
|
463
|
+
provider. Applying a theme sets the attribute, toggles the `dark` class, updates the `theme-color` meta
|
|
464
|
+
(`#05060A` / `#EEF1F8`) and writes `localStorage.theme` inside try/catch (storage can be blocked).
|
|
465
|
+
- **Modal focus** `(dialogRef, onClose, initialFocus?)`: LAYOUT-NAV.md §6.
|
|
466
|
+
- **Media query** `(query) → boolean`: `useSyncExternalStore` over `matchMedia`, with a `change` listener.
|
|
467
|
+
- **Dismiss** `(open, containerRef, onDismiss(reason))`: while open, a `pointerdown` outside the container or Escape
|
|
468
|
+
calls back with `'outside'` or `'escape'`; for non-modal popovers. Keep the callback in a ref so the listeners are
|
|
469
|
+
not re-bound on every render.
|
|
470
|
+
|
|
471
|
+
## Root providers
|
|
472
|
+
|
|
473
|
+
Wrap the app, outermost first: the data-cache provider, `MotionConfig reducedMotion="user"`, the router, the reward
|
|
474
|
+
provider, the toast provider. Both providers portal their overlays to `<body>`, outside `#root`, so they stay usable
|
|
475
|
+
while a dialog makes `#root` inert.
|
|
476
|
+
|
|
477
|
+
## The gallery page
|
|
478
|
+
|
|
479
|
+
Build a development-only route (`/dev/ui`, registered only in development builds) **before any product page**:
|
|
480
|
+
|
|
481
|
+
- Sections with anchors: Icons (every icon at 24 px + a tone strip), Buttons (every size x variant x state), Progress
|
|
482
|
+
(rings, XP bar, level badges, streak pills), Cards, Path (every node state, both layouts), Quests, Chips,
|
|
483
|
+
Achievements, Controls, Rewards (buttons that trigger a 10 XP and a 60 XP gain, a level-up, an achievement), Toasts.
|
|
484
|
+
- A sticky header with a theme toggle and a live `XpBar` marked `data-xp-target`, so the burst has somewhere to
|
|
485
|
+
land; credit the XP to that bar 700 ms after the trigger, when the chip arrives.
|
|
486
|
+
- Each example in a labelled `<figure>` with a mono caption naming the props.
|
|
487
|
+
- Exclude the gallery's folder from Tailwind's `content` in production builds, so gallery-only utilities never ship.
|
|
488
|
+
|
|
489
|
+
It is the fastest way to check both themes, 320 px width, keyboard focus and reduced motion for every component at
|
|
490
|
+
once, and it is where a new icon set is judged.
|