division-ds 0.3.1 → 0.4.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/AGENTS.md +2 -2
- package/package.json +1 -1
- package/public/docs/components/chart-panel.md +57 -42
- package/public/docs/components/code-block.md +106 -0
- package/public/docs/components/dropdown-menu.md +1 -0
- package/public/docs/components/kbd.md +24 -3
- package/public/docs/components/navbar.md +54 -3
- package/public/docs/components/panel.md +139 -0
- package/public/docs/components/progress.md +1 -1
- package/public/docs/components/terminal.md +405 -0
- package/public/manifest/components.json +581 -12
- package/public/manifest/tokens.json +178 -7
- package/scripts/lib/component-props.mjs +10 -1
- package/skills/division-ds/SKILL.md +1 -1
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Division DS: instructions for coding agents
|
|
2
2
|
|
|
3
|
-
A React 19 + Tailwind 4 + Radix design system:
|
|
3
|
+
A React 19 + Tailwind 4 + Radix design system: 75 components, tokens in three layers, light and
|
|
4
4
|
dark themes, WCAG 2.2 AA. This file is the entry point. It is short on purpose; everything it
|
|
5
5
|
points to is generated from the code, so it is current.
|
|
6
6
|
|
|
@@ -51,7 +51,7 @@ installs these rules into that project's `AGENTS.md`, `GEMINI.md` and Cursor rul
|
|
|
51
51
|
`.claude/skills/` (Claude Code).
|
|
52
52
|
|
|
53
53
|
An agent that supports MCP can have the docs and the same checks as tools instead:
|
|
54
|
-
`claude mcp add division-ds -- npx -y division-ds@0.
|
|
54
|
+
`claude mcp add division-ds -- npx -y division-ds@0.4.0 mcp` (`list_components`, `get_component`,
|
|
55
55
|
`search`, `get_tokens`, `validate_code`, `check_contrast`, `get_add_command`,
|
|
56
56
|
`get_review_checklist`).
|
|
57
57
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "division-ds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Checks a project that uses Division DS components (raw colours, invented tokens, touching buttons, unknown props), and serves the docs and the same checks to agents over MCP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Victor Ilioiu",
|
|
@@ -59,20 +59,26 @@ Each is compiled and rendered on the docs page. Imports are omitted; see above.
|
|
|
59
59
|
type Week = { week: string; online: number; store: number }
|
|
60
60
|
|
|
61
61
|
const WEEKS: Week[] = [
|
|
62
|
-
{ week: 'W1', online:
|
|
63
|
-
{ week: 'W2', online:
|
|
64
|
-
{ week: 'W3', online:
|
|
65
|
-
{ week: 'W4', online:
|
|
66
|
-
{ week: 'W5', online:
|
|
67
|
-
{ week: 'W6', online:
|
|
68
|
-
{ week: 'W7', online:
|
|
69
|
-
{ week: 'W8', online:
|
|
62
|
+
{ week: 'W1', online: 118, store: 150 },
|
|
63
|
+
{ week: 'W2', online: 149, store: 172 },
|
|
64
|
+
{ week: 'W3', online: 168, store: 158 },
|
|
65
|
+
{ week: 'W4', online: 141, store: 131 },
|
|
66
|
+
{ week: 'W5', online: 126, store: 128 },
|
|
67
|
+
{ week: 'W6', online: 174, store: 150 },
|
|
68
|
+
{ week: 'W7', online: 231, store: 141 },
|
|
69
|
+
{ week: 'W8', online: 183, store: 122 },
|
|
70
|
+
{ week: 'W9', online: 139, store: 149 },
|
|
71
|
+
{ week: 'W10', online: 162, store: 185 },
|
|
72
|
+
{ week: 'W11', online: 196, store: 163 },
|
|
73
|
+
{ week: 'W12', online: 170, store: 140 },
|
|
70
74
|
]
|
|
71
75
|
|
|
72
76
|
<ChartPanel<Week>
|
|
73
77
|
title="Weekly orders"
|
|
74
|
-
summary="Online orders
|
|
78
|
+
summary="Online orders peaked three times in twelve weeks, highest at 231 in week 7; in-store orders peaked highest at 185 in week 10."
|
|
75
79
|
kind="line"
|
|
80
|
+
area
|
|
81
|
+
curve="smooth"
|
|
76
82
|
data={WEEKS}
|
|
77
83
|
xKey="week"
|
|
78
84
|
xLabel="Week"
|
|
@@ -116,17 +122,17 @@ type Day = { day: string; visits: number; orders: number }
|
|
|
116
122
|
|
|
117
123
|
const DAYS: Day[] = [
|
|
118
124
|
{ day: 'Mon', visits: 1840, orders: 61 },
|
|
119
|
-
{ day: 'Tue', visits:
|
|
120
|
-
{ day: 'Wed', visits:
|
|
121
|
-
{ day: 'Thu', visits:
|
|
122
|
-
{ day: 'Fri', visits:
|
|
125
|
+
{ day: 'Tue', visits: 2960, orders: 104 },
|
|
126
|
+
{ day: 'Wed', visits: 2210, orders: 74 },
|
|
127
|
+
{ day: 'Thu', visits: 1720, orders: 55 },
|
|
128
|
+
{ day: 'Fri', visits: 2650, orders: 92 },
|
|
123
129
|
{ day: 'Sat', visits: 3890, orders: 141 },
|
|
124
|
-
{ day: 'Sun', visits:
|
|
130
|
+
{ day: 'Sun', visits: 3120, orders: 118 },
|
|
125
131
|
]
|
|
126
132
|
|
|
127
133
|
<ChartPanel<Day>
|
|
128
134
|
title="Visits this week"
|
|
129
|
-
summary="Visits
|
|
135
|
+
summary="Visits peaked on Tuesday at 2,960, fell to a Thursday low of 1,720, then peaked higher on Saturday at 3,890."
|
|
130
136
|
kind="line"
|
|
131
137
|
area
|
|
132
138
|
curve="smooth"
|
|
@@ -134,7 +140,7 @@ const DAYS: Day[] = [
|
|
|
134
140
|
xKey="day"
|
|
135
141
|
xLabel="Day"
|
|
136
142
|
series={[{ key: 'visits', label: 'Visits' }]}
|
|
137
|
-
headline="
|
|
143
|
+
headline="18,390"
|
|
138
144
|
headingLevel={4}
|
|
139
145
|
/>
|
|
140
146
|
```
|
|
@@ -145,19 +151,23 @@ const DAYS: Day[] = [
|
|
|
145
151
|
type Week = { week: string; online: number; store: number }
|
|
146
152
|
|
|
147
153
|
const WEEKS: Week[] = [
|
|
148
|
-
{ week: 'W1', online:
|
|
149
|
-
{ week: 'W2', online:
|
|
150
|
-
{ week: 'W3', online:
|
|
151
|
-
{ week: 'W4', online:
|
|
152
|
-
{ week: 'W5', online:
|
|
153
|
-
{ week: 'W6', online:
|
|
154
|
-
{ week: 'W7', online:
|
|
155
|
-
{ week: 'W8', online:
|
|
154
|
+
{ week: 'W1', online: 118, store: 150 },
|
|
155
|
+
{ week: 'W2', online: 149, store: 172 },
|
|
156
|
+
{ week: 'W3', online: 168, store: 158 },
|
|
157
|
+
{ week: 'W4', online: 141, store: 131 },
|
|
158
|
+
{ week: 'W5', online: 126, store: 128 },
|
|
159
|
+
{ week: 'W6', online: 174, store: 150 },
|
|
160
|
+
{ week: 'W7', online: 231, store: 141 },
|
|
161
|
+
{ week: 'W8', online: 183, store: 122 },
|
|
162
|
+
{ week: 'W9', online: 139, store: 149 },
|
|
163
|
+
{ week: 'W10', online: 162, store: 185 },
|
|
164
|
+
{ week: 'W11', online: 196, store: 163 },
|
|
165
|
+
{ week: 'W12', online: 170, store: 140 },
|
|
156
166
|
]
|
|
157
167
|
|
|
158
168
|
<ChartPanel<Week>
|
|
159
169
|
title="Weekly orders, gridless"
|
|
160
|
-
summary="Online orders
|
|
170
|
+
summary="Online orders peaked three times in twelve weeks, highest at 231 in week 7; in-store orders peaked highest at 185 in week 10."
|
|
161
171
|
kind="line"
|
|
162
172
|
area
|
|
163
173
|
curve="smooth"
|
|
@@ -206,30 +216,34 @@ type Week = { week: string; online: number; store: number }
|
|
|
206
216
|
type Day = { day: string; visits: number; orders: number }
|
|
207
217
|
|
|
208
218
|
const WEEKS: Week[] = [
|
|
209
|
-
{ week: 'W1', online:
|
|
210
|
-
{ week: 'W2', online:
|
|
211
|
-
{ week: 'W3', online:
|
|
212
|
-
{ week: 'W4', online:
|
|
213
|
-
{ week: 'W5', online:
|
|
214
|
-
{ week: 'W6', online:
|
|
215
|
-
{ week: 'W7', online:
|
|
216
|
-
{ week: 'W8', online:
|
|
219
|
+
{ week: 'W1', online: 118, store: 150 },
|
|
220
|
+
{ week: 'W2', online: 149, store: 172 },
|
|
221
|
+
{ week: 'W3', online: 168, store: 158 },
|
|
222
|
+
{ week: 'W4', online: 141, store: 131 },
|
|
223
|
+
{ week: 'W5', online: 126, store: 128 },
|
|
224
|
+
{ week: 'W6', online: 174, store: 150 },
|
|
225
|
+
{ week: 'W7', online: 231, store: 141 },
|
|
226
|
+
{ week: 'W8', online: 183, store: 122 },
|
|
227
|
+
{ week: 'W9', online: 139, store: 149 },
|
|
228
|
+
{ week: 'W10', online: 162, store: 185 },
|
|
229
|
+
{ week: 'W11', online: 196, store: 163 },
|
|
230
|
+
{ week: 'W12', online: 170, store: 140 },
|
|
217
231
|
]
|
|
218
232
|
|
|
219
233
|
const DAYS: Day[] = [
|
|
220
234
|
{ day: 'Mon', visits: 1840, orders: 61 },
|
|
221
|
-
{ day: 'Tue', visits:
|
|
222
|
-
{ day: 'Wed', visits:
|
|
223
|
-
{ day: 'Thu', visits:
|
|
224
|
-
{ day: 'Fri', visits:
|
|
235
|
+
{ day: 'Tue', visits: 2960, orders: 104 },
|
|
236
|
+
{ day: 'Wed', visits: 2210, orders: 74 },
|
|
237
|
+
{ day: 'Thu', visits: 1720, orders: 55 },
|
|
238
|
+
{ day: 'Fri', visits: 2650, orders: 92 },
|
|
225
239
|
{ day: 'Sat', visits: 3890, orders: 141 },
|
|
226
|
-
{ day: 'Sun', visits:
|
|
240
|
+
{ day: 'Sun', visits: 3120, orders: 118 },
|
|
227
241
|
]
|
|
228
242
|
|
|
229
243
|
<ChartPanel<Day>
|
|
230
244
|
title="Visits"
|
|
231
|
-
headline="
|
|
232
|
-
summary="
|
|
245
|
+
headline="18,390"
|
|
246
|
+
summary="Two peaks: Tuesday, then a higher Saturday."
|
|
233
247
|
kind="line"
|
|
234
248
|
area
|
|
235
249
|
curve="smooth"
|
|
@@ -254,9 +268,10 @@ const DAYS: Day[] = [
|
|
|
254
268
|
/>
|
|
255
269
|
<ChartPanel<Week>
|
|
256
270
|
title="Online orders"
|
|
257
|
-
headline="
|
|
258
|
-
summary="
|
|
271
|
+
headline="170"
|
|
272
|
+
summary="Three peaks in twelve weeks; the highest, 231, in week 7."
|
|
259
273
|
kind="line"
|
|
274
|
+
area
|
|
260
275
|
curve="smooth"
|
|
261
276
|
size="sm"
|
|
262
277
|
data={WEEKS}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# CodeBlock
|
|
2
|
+
|
|
3
|
+
> Code or a command in a panel, with a title bar that names the file or language and a button that copies the text. Long lines scroll sideways inside it, and code longer than one line gets line numbers.
|
|
4
|
+
|
|
5
|
+
- **Best for:** Showing code or a command someone will read or copy: an install step, a config file, an example.
|
|
6
|
+
- **Not for:** A word of code inside a sentence: use a code element. A key to press: use Kbd.
|
|
7
|
+
- Molecule. Source: `src/components/molecules/code-block/CodeBlock.tsx`
|
|
8
|
+
- Rendered docs page: `/components/code-block`
|
|
9
|
+
|
|
10
|
+
## Import
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { CodeBlock } from 'src/components/molecules/code-block/CodeBlock'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Paths are from the Division DS repository root. Installed with shadcn they start `src/division-ds/` instead of `src/` (`src/division-ds/components/...`); import them relative to your file. An install has no index barrels: import each component from its own file, never from `components/molecules`.
|
|
17
|
+
|
|
18
|
+
## Requires
|
|
19
|
+
|
|
20
|
+
- The app’s one Toaster at the root: the copy is confirmed with a toast.
|
|
21
|
+
|
|
22
|
+
## Props
|
|
23
|
+
|
|
24
|
+
| Prop | Type | Default | Description |
|
|
25
|
+
|---|---|---|---|
|
|
26
|
+
| `code` | `string` | | The text shown and copied, exactly. |
|
|
27
|
+
| `label` | `string` | | What the code is, in a few words ("the theme CSS"). Names the region and the copy button ("Copy the theme CSS"). |
|
|
28
|
+
| `title` | `string` | | Shown in the title bar: a file name ("index.css") or a language ("bash"). |
|
|
29
|
+
| `language` | `'css' \| 'text'` | `'text'` | css colours comments, at-rules, selectors and property names; text is plain. |
|
|
30
|
+
| `lineNumbers` | `boolean` | | Line numbers in a gutter. Unset, they show when the code has more than one line. |
|
|
31
|
+
| `copyable` | `boolean` | `true` | The copy button. Turn it off for code nobody should paste, such as a wrong example. |
|
|
32
|
+
| `wrap` | `boolean` | `false` | Wraps long lines instead of scrolling them sideways. For prose, such as a prompt; leave code unwrapped. |
|
|
33
|
+
| `className` | `string` | | Merged onto the frame. Use it for width (max-w-3xl) and spacing. |
|
|
34
|
+
| `ref` | `Ref<HTMLDivElement>` | | Passed through to the frame. |
|
|
35
|
+
|
|
36
|
+
## Examples
|
|
37
|
+
|
|
38
|
+
Each is compiled and rendered on the docs page. Imports are omitted; see above.
|
|
39
|
+
|
|
40
|
+
### A command
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
<CodeBlock title="bash" label="the check command" code="npx division-ds check src" className="max-w-3xl" />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### A file, with CSS colours and line numbers
|
|
47
|
+
|
|
48
|
+
```tsx
|
|
49
|
+
<CodeBlock
|
|
50
|
+
title="index.css"
|
|
51
|
+
language="css"
|
|
52
|
+
label="the theme CSS"
|
|
53
|
+
className="max-w-3xl"
|
|
54
|
+
code={'@import "./division-ds/styles/division-ds.css";\n\n/* Square corners */\n:root {\n --shape-bevel: 0;\n --shape-radius: 4px;\n}\n'}
|
|
55
|
+
/>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Not copyable, for code nobody should paste
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
<CodeBlock title="Wrong" label="a bare pre" copyable={false} code={'<pre>{command}</pre>'} className="max-w-3xl" />
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Keyboard
|
|
65
|
+
|
|
66
|
+
| Keys | Result |
|
|
67
|
+
|---|---|
|
|
68
|
+
| `Tab` | Moves to the copy button, then to the code region. |
|
|
69
|
+
| `←` `→` | In the focused code region: scrolls a long line sideways. |
|
|
70
|
+
| `Enter` | On the copy button: copies the code. |
|
|
71
|
+
|
|
72
|
+
## Do
|
|
73
|
+
|
|
74
|
+
- Write a label that says what the code is, so the copy button reads "Copy the install command".
|
|
75
|
+
- Give it a title: the file name it belongs in, or the language.
|
|
76
|
+
- Set a max width with className; long lines scroll inside it, so it never widens the page.
|
|
77
|
+
|
|
78
|
+
## Don't
|
|
79
|
+
|
|
80
|
+
- Don’t put several unrelated commands in one block. One block per thing to copy.
|
|
81
|
+
- Don’t set copyable on an example of what not to write.
|
|
82
|
+
- Don’t wrap it in another bordered panel; it brings its own frame.
|
|
83
|
+
|
|
84
|
+
## Common mistakes
|
|
85
|
+
|
|
86
|
+
Wrong:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
<pre className="font-mono text-sm">{command}</pre>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Right:
|
|
93
|
+
|
|
94
|
+
```tsx
|
|
95
|
+
<CodeBlock code={command} label="the install command" title="bash" />
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A bare pre has no copy button, no name, and cannot be scrolled with a keyboard when a line runs past the edge.
|
|
99
|
+
|
|
100
|
+
## Anatomy
|
|
101
|
+
|
|
102
|
+
- **Frame**: A thin border around a surface.base fill. The syntax colours are measured for contrast on surface.base.
|
|
103
|
+
- **Title bar**: The title on the left, in 12px uppercase mono, and the copy button on the right, above a thin line.
|
|
104
|
+
- **Code region**: A pre with role region, named by the title and the label, focusable so a keyboard can scroll it. Up to 32rem tall, then it scrolls.
|
|
105
|
+
- **Line numbers**: A gutter in text.muted, hidden from screen readers and from text selection.
|
|
106
|
+
- **Copy button**: An IconButton named "Copy" plus the label. After copying, its icon turns into a tick for a moment and a toast confirms it.
|
|
@@ -29,6 +29,7 @@ Paths are from the Division DS repository root. Installed with shadcn they start
|
|
|
29
29
|
| `onSelect (Item)` | `(event: Event) => void` | | Called when the item is chosen. |
|
|
30
30
|
| `disabled (Item)` | `boolean` | `false` | The item can't be chosen, and typing letters (typeahead) skips it. |
|
|
31
31
|
| `tone (Item)` | `'default' \| 'hostile'` | `'default'` | Use hostile for a destructive action: hostile-coloured text at rest, the hostile fill with ink text when highlighted. |
|
|
32
|
+
| `asChild (Item)` | `boolean` | `false` | Makes the one child (a link) the item, for a menu of links. icon and shortcut are ignored then; put the content inside the link. |
|
|
32
33
|
| `icon (Item)` | `ReactNode` | | A small icon before the text, hidden from screen readers (aria-hidden). |
|
|
33
34
|
| `shortcut (Item)` | `string` | | Shown on the right and passed to screen readers as aria-keyshortcuts. It only displays the key: the menu never makes the key work. |
|
|
34
35
|
| `checked (Checkbox item)` | `boolean` | | Whether the tick shows. |
|
|
@@ -20,6 +20,8 @@ Paths are from the Division DS repository root. Installed with shadcn they start
|
|
|
20
20
|
| Prop | Type | Default | Description |
|
|
21
21
|
|---|---|---|---|
|
|
22
22
|
| `children` | `ReactNode` | | The key's name, for example "Esc" or "⌘". |
|
|
23
|
+
| `size` | `'md' \| 'sm'` | `'md'` | md is 24px tall, for a cap beside text or in a menu row. sm is 20px tall, for a cap inside a 32px control: a small Button or a search field. |
|
|
24
|
+
| `cut` | `boolean` | `false` | Cuts the bottom-right corner (5px at sm, 8px at md) so the cap nests in the corner of a bevelled control, its diagonal parallel to the control's. Only for a cap inside such a control. |
|
|
23
25
|
| `className` | `string` | | Merged with the component's classes. When Tailwind utility classes clash, the later one wins. |
|
|
24
26
|
| `ref` | `Ref<HTMLElement>` | | Passed through to the kbd element. |
|
|
25
27
|
| `...rest` | `HTMLAttributes<HTMLElement>` | | Every native attribute, passed onto the kbd element, such as a title, or an aria-label for a symbol key (aria-label is the name screen readers read out). |
|
|
@@ -49,6 +51,24 @@ Each is compiled and rendered on the docs page. Imports are omitted; see above.
|
|
|
49
51
|
<span className="text-sm text-[var(--color-text-secondary)]">Open the command palette</span>
|
|
50
52
|
```
|
|
51
53
|
|
|
54
|
+
### Sizes
|
|
55
|
+
|
|
56
|
+
```tsx
|
|
57
|
+
<Kbd>Esc</Kbd>
|
|
58
|
+
<Kbd size="sm">Esc</Kbd>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Small and cut, inside a small button
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
<Button variant="secondary" size="sm" iconStart={<Search />} aria-keyshortcuts="Control+K">
|
|
65
|
+
Search
|
|
66
|
+
<Kbd aria-hidden="true" size="sm" cut className="-mr-1.5 ml-2 -translate-y-[var(--cap-shift,0px)]">
|
|
67
|
+
Ctrl K
|
|
68
|
+
</Kbd>
|
|
69
|
+
</Button>
|
|
70
|
+
```
|
|
71
|
+
|
|
52
72
|
## Keyboard
|
|
53
73
|
|
|
54
74
|
Not focusable. No keyboard behaviour of its own.
|
|
@@ -58,15 +78,16 @@ Not focusable. No keyboard behaviour of its own.
|
|
|
58
78
|
- Use one Kbd per physical key, and put them side by side for a chord (keys pressed together).
|
|
59
79
|
- Put it next to the action it triggers, in the same row or the same tooltip.
|
|
60
80
|
- Write the key name the way the keyboard prints it.
|
|
81
|
+
- Inside a 32px control, use size="sm"; inside a bevelled one (a Button), add cut and place the cap at the end, near the cut corner.
|
|
61
82
|
|
|
62
83
|
## Don't
|
|
63
84
|
|
|
64
|
-
- Don’t
|
|
85
|
+
- Don’t set cut on a cap that stands alone in text or a menu row. The cut answers a bevelled corner around it; without one it reads as a button.
|
|
65
86
|
- Don’t put a whole chord inside one Kbd ("Ctrl+K" in a single cap).
|
|
66
87
|
- Don’t use it for anything that isn’t a key. It’s not a badge.
|
|
67
88
|
|
|
68
89
|
## Anatomy
|
|
69
90
|
|
|
70
91
|
- **kbd element**: The HTML element made for keys. Screen readers announce it as keyboard input.
|
|
71
|
-
- **Hairline border**: A one-pixel border in border.hairline-strong
|
|
72
|
-
- **Mono legend**: JetBrains Mono, uppercase, 11px (pixels): the tertiary type role.
|
|
92
|
+
- **Hairline border**: A one-pixel border in border.hairline-strong. Square corners by default; with cut, the bottom-right corner is cut at 45 degrees and the border follows the diagonal.
|
|
93
|
+
- **Mono legend**: JetBrains Mono, uppercase, 11px (pixels): the tertiary type role, at both sizes.
|
|
@@ -21,11 +21,12 @@ Paths are from the Division DS repository root. Installed with shadcn they start
|
|
|
21
21
|
|---|---|---|---|
|
|
22
22
|
| `label` | `string` | | Required. The name screen readers give the navigation region. |
|
|
23
23
|
| `brand` | `ReactNode` | | Required. The wordmark or logo, usually a link to the home page. |
|
|
24
|
-
| `items` | `NavbarItem[]` | | Required.
|
|
24
|
+
| `items` | `NavbarItem[]` | | Required. A link is { label, href, current }. A menu among the links is { label, menu, current }: menu lists { label, href, description } entries, opened from a dropdown on a wide bar and listed as a labelled group in the menu sheet on a narrow one. |
|
|
25
25
|
| `actions` | `ReactNode` | | Controls on the right: icon buttons, a cart link, an account menu. Keep them small, because they stay visible at every width. |
|
|
26
26
|
| `renderLink` | `(props: LinkRenderProps) => ReactNode` | `a plain anchor` | Pass your router's link component here. Map href to its own prop, and pass className, aria-current and onClick through. |
|
|
27
27
|
| `menuLabel` | `string` | `'Menu'` | The menu button's name for screen readers, and the sheet's title. |
|
|
28
|
-
| `menuFooter` | `ReactNode` | | Shown in the menu sheet under the links. Use it for an action that doesn't fit in actions on a narrow bar. Hide the matching copy in actions below the breakpoint by wrapping it in an element with the classes hidden @2xl:flex. |
|
|
28
|
+
| `menuFooter` | `ReactNode` | | Shown in the menu sheet under the links. Use it for an action that doesn't fit in actions on a narrow bar. Hide the matching copy in actions below the breakpoint by wrapping it in an element with the classes hidden @2xl:flex (hidden @4xl:flex when collapseBelow is '4xl'). |
|
|
29
|
+
| `collapseBelow` | `'2xl' \| '4xl'` | `'2xl'` | The bar's own width below which the links fold into the menu sheet: 2xl is 42rem, 4xl is 56rem. Pick the one at which the brand, every link and the actions still fit on one row with room to spare. |
|
|
29
30
|
| `className` | `string` | | Added to the root classes. Where two Tailwind utility classes clash, the later one wins. |
|
|
30
31
|
| `ref` | `Ref<HTMLElement>` | | The header element. |
|
|
31
32
|
|
|
@@ -34,7 +35,7 @@ Paths are from the Division DS repository root. Installed with shadcn they start
|
|
|
34
35
|
Exported beside the component, from the same file. Import a type with `import type { ... }`.
|
|
35
36
|
|
|
36
37
|
```ts
|
|
37
|
-
export type NavbarItem =
|
|
38
|
+
export type NavbarItem = NavbarLink | NavbarMenu
|
|
38
39
|
```
|
|
39
40
|
|
|
40
41
|
## Examples
|
|
@@ -77,6 +78,56 @@ const ACTIONS = (
|
|
|
77
78
|
<Navbar label="Store navigation" brand={BRAND} items={ITEMS} actions={ACTIONS} />
|
|
78
79
|
```
|
|
79
80
|
|
|
81
|
+
### A menu among the links
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
const ITEMS = [
|
|
85
|
+
{ label: 'Replicas', href: '#replicas' },
|
|
86
|
+
{ label: 'Optics', href: '#optics', current: true },
|
|
87
|
+
{ label: 'Parts', href: '#parts' },
|
|
88
|
+
{ label: 'Care', href: '#care' },
|
|
89
|
+
{ label: 'Field notes', href: '#field-notes' },
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
const BRAND = (
|
|
93
|
+
<a
|
|
94
|
+
href="#home"
|
|
95
|
+
className="inline-flex items-center min-h-10 font-display font-bold uppercase tracking-[0.14em] text-[var(--color-text-primary)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--color-focus-ring)]"
|
|
96
|
+
>
|
|
97
|
+
Hexline
|
|
98
|
+
</a>
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
const ACTIONS = (
|
|
102
|
+
<>
|
|
103
|
+
<IconButton label="Search" variant="ghost">
|
|
104
|
+
<Search aria-hidden="true" className="w-5 h-5" />
|
|
105
|
+
</IconButton>
|
|
106
|
+
<IconButton label="Cart, 2 items" variant="ghost" asChild>
|
|
107
|
+
<a href="#cart">
|
|
108
|
+
<ShoppingBag aria-hidden="true" className="w-5 h-5" />
|
|
109
|
+
</a>
|
|
110
|
+
</IconButton>
|
|
111
|
+
</>
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
<Navbar
|
|
115
|
+
label="Store navigation with a menu"
|
|
116
|
+
brand={BRAND}
|
|
117
|
+
items={[
|
|
118
|
+
...ITEMS.slice(0, 3),
|
|
119
|
+
{
|
|
120
|
+
label: 'Guides',
|
|
121
|
+
menu: [
|
|
122
|
+
{ label: 'Sizing', href: '#sizing', description: 'Fit charts for every replica.' },
|
|
123
|
+
{ label: 'Returns', href: '#returns', description: 'Thirty days, no questions.' },
|
|
124
|
+
],
|
|
125
|
+
},
|
|
126
|
+
]}
|
|
127
|
+
actions={ACTIONS}
|
|
128
|
+
/>
|
|
129
|
+
```
|
|
130
|
+
|
|
80
131
|
### A narrow container
|
|
81
132
|
|
|
82
133
|
```tsx
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# Panel
|
|
2
|
+
|
|
3
|
+
> The system's framed surface: a thin border around a fill, with the crosshair corner marks and the cut corner as options. Card is a Panel with a title, body and footer; Panel is the frame alone, for a feature tile, a demo frame or a tile that is one link.
|
|
4
|
+
|
|
5
|
+
- **Best for:** Framing content that has no title, body and footer structure: a feature tile, a demo area, or a tile that is one link.
|
|
6
|
+
- **Not for:** Content with a title, a body and actions: use Card. A page-width layout wrapper: use a plain div with max-w-*.
|
|
7
|
+
- Atom. Source: `src/components/atoms/panel/Panel.tsx`
|
|
8
|
+
- Rendered docs page: `/components/panel`
|
|
9
|
+
|
|
10
|
+
## Import
|
|
11
|
+
|
|
12
|
+
```tsx
|
|
13
|
+
import { Panel } from 'src/components/atoms/panel/Panel'
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Paths are from the Division DS repository root. Installed with shadcn they start `src/division-ds/` instead of `src/` (`src/division-ds/components/...`); import them relative to your file. An install has no index barrels: import each component from its own file, never from `components/molecules`.
|
|
17
|
+
|
|
18
|
+
## Props
|
|
19
|
+
|
|
20
|
+
| Prop | Type | Default | Description |
|
|
21
|
+
|---|---|---|---|
|
|
22
|
+
| `padding` | `'none' \| 'sm' \| 'md' \| 'lg'` | `'md'` | Inner spacing: 0, 12px, 20px or 32px. |
|
|
23
|
+
| `tone` | `'base' \| 'raised' \| 'signal'` | `'raised'` | base sits flush with the page, raised is one step up, signal is the brand wash for the one panel in a group that leads. |
|
|
24
|
+
| `crosshair` | `boolean` | `false` | Draws the crosshair marks at the corners. |
|
|
25
|
+
| `cut` | `boolean` | `false` | Cuts the bottom-right corner, with the border following the cut. |
|
|
26
|
+
| `interactive` | `boolean` | `false` | Hover and focus states for a panel that is one link or button. Use it with asChild; it adds no behaviour of its own. |
|
|
27
|
+
| `asChild` | `boolean` | `false` | Renders the single child element (an a, a router Link, a button) with the panel classes merged onto it, instead of a div. |
|
|
28
|
+
| `className` | `string` | | Merged with the component's classes. Use it for layout (a grid span, flex, gap), not for the fill or the border. |
|
|
29
|
+
| `ref` | `Ref<HTMLDivElement>` | | Passed through to the div, or to the child with asChild. |
|
|
30
|
+
| `...rest` | `HTMLAttributes<HTMLDivElement>` | | Every native attribute, passed onto the element. |
|
|
31
|
+
|
|
32
|
+
## Examples
|
|
33
|
+
|
|
34
|
+
Each is compiled and rendered on the docs page. Imports are omitted; see above.
|
|
35
|
+
|
|
36
|
+
### Tones
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
<Panel tone="base">
|
|
40
|
+
<p className="font-display font-semibold">Base</p>
|
|
41
|
+
<p className="text-sm text-[var(--color-text-secondary)]">Flush with the page.</p>
|
|
42
|
+
</Panel>
|
|
43
|
+
<Panel tone="raised">
|
|
44
|
+
<p className="font-display font-semibold">Raised</p>
|
|
45
|
+
<p className="text-sm text-[var(--color-text-secondary)]">One step up.</p>
|
|
46
|
+
</Panel>
|
|
47
|
+
<Panel tone="signal">
|
|
48
|
+
<p className="font-display font-semibold">Signal</p>
|
|
49
|
+
<p className="text-sm text-[var(--color-text-secondary)]">The one that leads.</p>
|
|
50
|
+
</Panel>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Padding
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Panel padding="none">none</Panel>
|
|
57
|
+
<Panel padding="sm">sm</Panel>
|
|
58
|
+
<Panel padding="md">md</Panel>
|
|
59
|
+
<Panel padding="lg">lg</Panel>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Crosshair and cut corner
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
<Panel crosshair>Crosshair</Panel>
|
|
66
|
+
<Panel cut>Cut corner</Panel>
|
|
67
|
+
<Panel crosshair cut tone="signal">Both</Panel>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Interactive, as a router link
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
<Panel interactive cut padding="lg" asChild>
|
|
74
|
+
<RouterLink to="/components/card" className="flex flex-col gap-3">
|
|
75
|
+
<span className="font-display text-lg font-semibold">Card</span>
|
|
76
|
+
<span className="text-sm text-[var(--color-text-secondary)]">A panel with a title, a body and a footer.</span>
|
|
77
|
+
<span className="inline-flex items-center gap-2 font-semibold text-[var(--color-accent-signal-text)]">
|
|
78
|
+
Open <ArrowRight aria-hidden="true" className="size-4" />
|
|
79
|
+
</span>
|
|
80
|
+
</RouterLink>
|
|
81
|
+
</Panel>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Keyboard
|
|
85
|
+
|
|
86
|
+
| Keys | Result |
|
|
87
|
+
|---|---|
|
|
88
|
+
| `Tab` | With interactive and asChild on a link or button: moves focus to the panel and shows the focus ring. |
|
|
89
|
+
| `Enter` | Follows the link, or presses the button, that the panel was rendered as. |
|
|
90
|
+
|
|
91
|
+
## Do
|
|
92
|
+
|
|
93
|
+
- Use signal on at most one panel in a group: the one that leads.
|
|
94
|
+
- Give a clickable panel interactive and asChild, with a real link or button as the child.
|
|
95
|
+
- Leave 8px around a panel with the crosshair, so a parent that clips does not cut the marks off.
|
|
96
|
+
|
|
97
|
+
## Don't
|
|
98
|
+
|
|
99
|
+
- Don’t put a button near the bottom-right corner of a cut panel; the cut can clip it.
|
|
100
|
+
- Don’t set a fill or border colour with a class. Choose a tone.
|
|
101
|
+
- Don’t put a second link or button inside an interactive panel.
|
|
102
|
+
|
|
103
|
+
## Common mistakes
|
|
104
|
+
|
|
105
|
+
Wrong:
|
|
106
|
+
|
|
107
|
+
```tsx
|
|
108
|
+
<Panel className="bg-[var(--color-surface-base)] border-[var(--color-border-selection)]">
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Right:
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
<Panel tone="base">
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
The panel's fill and border come from its tone, through CSS that sits outside Tailwind's layers, so a bg- or border- class never wins. Pick the tone.
|
|
118
|
+
|
|
119
|
+
Wrong:
|
|
120
|
+
|
|
121
|
+
```tsx
|
|
122
|
+
<Panel interactive onClick={open}>Replicas</Panel>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Right:
|
|
126
|
+
|
|
127
|
+
```tsx
|
|
128
|
+
<Panel interactive asChild><Link to="/replicas">Replicas</Link></Panel>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
A div with a click handler cannot be reached by keyboard and is not announced as a link. interactive styles a panel that already is a link or a button; asChild makes it one.
|
|
132
|
+
|
|
133
|
+
## Anatomy
|
|
134
|
+
|
|
135
|
+
- **Frame**: A div (or, with asChild, your element) with the .panel class: a one-pixel border and a fill, both set by the tone.
|
|
136
|
+
- **Tone**: base: surface.base fill, border.hairline border. raised: surface.raised fill, border.hairline border. signal: accent.signal.wash fill, border.selection border. All tokens, so each one is right in both themes.
|
|
137
|
+
- **Crosshair**: Optional. Short marks drawn 5px outside each corner, in text.muted. The parent must not clip its overflow.
|
|
138
|
+
- **Cut corner**: Optional. The bottom-right corner cut at 45 degrees (14px), with the border drawn along the cut, so the outline does not break at that corner. With the crosshair on, the bottom-right marks fall inside the cut and are not drawn.
|
|
139
|
+
- **Interactive state**: Optional. On hover and on keyboard focus the border, diagonal included, turns accent.signal.indicator; keyboard focus also draws the focus ring 2px outside. Nothing moves.
|
|
@@ -23,7 +23,7 @@ Paths are from the Division DS repository root. Installed with shadcn they start
|
|
|
23
23
|
| `value` | `number \| null` | | null means indeterminate. The value is clamped to [0, max], so an out-of-range value shows as complete instead of overflowing the track. |
|
|
24
24
|
| `max` | `number` | `100` | The value at which the bar is complete. |
|
|
25
25
|
| `showValue` | `boolean` | `false` | Shows the percentage (or "In progress") as a readout. |
|
|
26
|
-
| `tone` | `'signal' \| 'ok' \| 'warning' \| 'hostile'` | `'signal'` | The fill colour. signal paints accent.signal.indicator to match Slider. On the track in light theme that’s a 2.
|
|
26
|
+
| `tone` | `'signal' \| 'ok' \| 'warning' \| 'hostile'` | `'signal'` | The fill colour. signal paints accent.signal.indicator to match Slider. On the track in light theme that’s a 2.80:1 contrast ratio, below the 3:1 a bar needs when it’s the only sign of progress. So set showValue there. |
|
|
27
27
|
| `className` | `string` | | Merged with the outer wrapper’s classes. Later Tailwind utilities (Tailwind is the CSS framework the system is styled with) win. |
|
|
28
28
|
| `ref` | `Ref<HTMLDivElement>` | | Passed through to the Radix Progress root, which is the bar itself. Radix is the library of accessible building blocks this component sits on. |
|
|
29
29
|
| `...rest` | `Omit<HTMLAttributes<HTMLDivElement>, 'children'>` | | Every native div prop except children, spread onto the outer wrapper, so a molecule can attach a data-testid there. children is typed away because this component draws its own label row and track, and a children prop would be thrown away without any warning. |
|