@charcuterie/ui 4.30.0 → 4.31.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/README.md +7 -2
- package/docs/README.md +573 -0
- package/docs/building-an-app.md +231 -0
- package/docs/components/Accordion.md +106 -0
- package/docs/components/ActionMenu.md +63 -0
- package/docs/components/ActionTiles.md +233 -0
- package/docs/components/AdaptiveGrid.md +215 -0
- package/docs/components/Alert.md +99 -0
- package/docs/components/AnchorLink.md +23 -0
- package/docs/components/Avatar.md +153 -0
- package/docs/components/Badge.md +81 -0
- package/docs/components/BadgeButton.md +84 -0
- package/docs/components/Board.md +277 -0
- package/docs/components/Breadcrumbs.md +87 -0
- package/docs/components/Button.md +72 -0
- package/docs/components/ButtonLink.md +81 -0
- package/docs/components/Card.md +114 -0
- package/docs/components/CatalogPicker.md +250 -0
- package/docs/components/Chart.md +39 -0
- package/docs/components/Checkbox.md +197 -0
- package/docs/components/ColorPicker.md +99 -0
- package/docs/components/ColorSchemeSwitcher.md +92 -0
- package/docs/components/ColorSchemeToggle.md +98 -0
- package/docs/components/Combobox.md +175 -0
- package/docs/components/CommandPalette.md +120 -0
- package/docs/components/ComparisonChart.md +31 -0
- package/docs/components/CopyButton.md +112 -0
- package/docs/components/DataTable.md +170 -0
- package/docs/components/DatePicker.md +225 -0
- package/docs/components/Dialog.md +134 -0
- package/docs/components/DropRail.md +107 -0
- package/docs/components/EmptyState.md +65 -0
- package/docs/components/Field.md +215 -0
- package/docs/components/FieldGroup.md +45 -0
- package/docs/components/FileDropZone.md +98 -0
- package/docs/components/GroupedList.md +189 -0
- package/docs/components/Header.md +76 -0
- package/docs/components/HtmlEditor-html-editor.md +76 -0
- package/docs/components/HtmlView-html-editor.md +47 -0
- package/docs/components/HtmlView-html-view.md +47 -0
- package/docs/components/IconButton.md +52 -0
- package/docs/components/LaneTimeline.md +254 -0
- package/docs/components/Lightbox.md +101 -0
- package/docs/components/Listbox.md +109 -0
- package/docs/components/LiveStatusIndicator.md +60 -0
- package/docs/components/LogViewer.md +142 -0
- package/docs/components/Main.md +247 -0
- package/docs/components/MarkdownEditor.md +262 -0
- package/docs/components/MarkdownEditorCodeMirror-markdown-editor-codemirror.md +230 -0
- package/docs/components/MarkdownLine.md +187 -0
- package/docs/components/MarkdownView-markdown-editor-codemirror.md +235 -0
- package/docs/components/MediaTile.md +106 -0
- package/docs/components/Menu.md +209 -0
- package/docs/components/MetricCard.md +38 -0
- package/docs/components/Modal.md +89 -0
- package/docs/components/Nav.md +167 -0
- package/docs/components/NavBar.md +190 -0
- package/docs/components/Picker.md +132 -0
- package/docs/components/Popover.md +135 -0
- package/docs/components/PortraitTiles.md +169 -0
- package/docs/components/ProgressBar.md +70 -0
- package/docs/components/ProgressCard.md +65 -0
- package/docs/components/QueryBuilder.md +132 -0
- package/docs/components/RadioGroup.md +165 -0
- package/docs/components/Rail.md +79 -0
- package/docs/components/RangeSlider.md +144 -0
- package/docs/components/ReactRouterAdapter-react-router.md +27 -0
- package/docs/components/ReactRouterLink-react-router.md +23 -0
- package/docs/components/ReorderList.md +143 -0
- package/docs/components/RouterLinkProvider.md +33 -0
- package/docs/components/ScheduleBoard.md +41 -0
- package/docs/components/ScrollMemoryProvider.md +33 -0
- package/docs/components/SearchInput.md +46 -0
- package/docs/components/SegmentedControl.md +98 -0
- package/docs/components/Select.md +169 -0
- package/docs/components/Shell.md +162 -0
- package/docs/components/Skeleton.md +48 -0
- package/docs/components/Slider.md +128 -0
- package/docs/components/SortableTableHeader.md +84 -0
- package/docs/components/Spinner.md +50 -0
- package/docs/components/Stepper.md +121 -0
- package/docs/components/Swatch.md +79 -0
- package/docs/components/Switch.md +80 -0
- package/docs/components/TableColumns.md +29 -0
- package/docs/components/TableViewport.md +42 -0
- package/docs/components/Tabs.md +184 -0
- package/docs/components/TextLink.md +106 -0
- package/docs/components/TimecodeInput.md +222 -0
- package/docs/components/Toast.md +108 -0
- package/docs/components/ToastRegion.md +35 -0
- package/docs/components/Toolbar.md +118 -0
- package/docs/components/Tooltip.md +94 -0
- package/docs/components/UnstyledLink.md +21 -0
- package/docs/components/ValuePairs.md +30 -0
- package/docs/components/VirtualizedGrid.md +204 -0
- package/docs/components/VisuallyHidden.md +39 -0
- package/docs/components/WeekdayIndicator.md +39 -0
- package/docs/hooks/useAdaptiveColumns.md +111 -0
- package/docs/hooks/useCommandPalette.md +40 -0
- package/docs/hooks/useCommandPaletteHotkeys.md +33 -0
- package/docs/hooks/useDeploymentUpdate.md +39 -0
- package/docs/hooks/useLastPresentValue.md +23 -0
- package/docs/hooks/useListMotion.md +65 -0
- package/docs/hooks/useNavLayout.md +59 -0
- package/docs/hooks/usePresence.md +39 -0
- package/docs/hooks/useRouterLink.md +22 -0
- package/docs/hooks/useValueChangeMotion.md +28 -0
- package/package.json +7 -5
- package/skills/charcuterie/SKILL.md +17 -0
- package/skills/charcuterie/references/build-a-screen.md +6 -0
- package/skills/charcuterie/references/create-a-component.md +6 -0
- package/src/AdaptiveGrid/AdaptiveGrid.stories.tsx +1 -1
- package/src/Tabs/Tabs.stories.tsx +1 -1
- package/src/VirtualizedGrid/VirtualizedGrid.stories.tsx +65 -28
- package/src/VirtualizedGrid/VirtualizedGrid.test.tsx +29 -0
- package/src/shell.storyHelpers.tsx +3 -3
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Board
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Board } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Lanes of cards, sized by their **container**, moved by keyboard or by pointer — and with
|
|
8
|
+
**no drag-and-drop dependency**.
|
|
9
|
+
|
|
10
|
+
## The container rule, and why it is the whole component
|
|
11
|
+
|
|
12
|
+
There is no media query anywhere in `Board`, `BoardCard` or `BoardLaneList`, and adding one
|
|
13
|
+
would be a defect rather than a shortcut. Two facts make window width useless here, and they
|
|
14
|
+
compound:
|
|
15
|
+
|
|
16
|
+
- **A lane in a three-up board is narrow on any monitor.** Three lanes across a 1600px window
|
|
17
|
+
is ~500px each — a phone's worth of room, on a 4K display, maximised.
|
|
18
|
+
- **A zoomed browser lies about pixels.** A 1500px window at 175% zoom is ~860 effective CSS
|
|
19
|
+
pixels, so the number a `@media` query reads is not the number of pixels anything has.
|
|
20
|
+
|
|
21
|
+
So there are **two nested containers**, answering two different questions:
|
|
22
|
+
|
|
23
|
+
| Container | Decides |
|
|
24
|
+
| --- | --- |
|
|
25
|
+
| the board's own box | how many lanes are on screen — three-up at `cq-lg`, otherwise one lane and a segmented control |
|
|
26
|
+
| each lane's wrapper | what shape a card is — two lines, one line, or its own card |
|
|
27
|
+
|
|
28
|
+
`Responsive` is the only honest way to show it: three fixed-width panels inside one browser
|
|
29
|
+
window that never moves. Resizing the viewport would prove nothing, because the thing that
|
|
30
|
+
changed is the component's container, not the window.
|
|
31
|
+
|
|
32
|
+
The narrow panel there is **not a phone**. It is the same board in a sidebar, in a split
|
|
33
|
+
window, or on a display somebody has zoomed to 175% — and a media query cannot tell any of
|
|
34
|
+
those apart from a maximised 4K window.
|
|
35
|
+
|
|
36
|
+
## Workflow columns and project-pool rows
|
|
37
|
+
|
|
38
|
+
The default `laneLayout="columns"` is for workflow stages. At `cq-lg` the lanes sit side by
|
|
39
|
+
side; below it, one selected lane stays on screen and a segmented control names the others.
|
|
40
|
+
|
|
41
|
+
`laneLayout="rows"` is for parallel project pools. Every lane becomes one horizontal band,
|
|
42
|
+
every lane stays visible, and the cards form a responsive grid inside their band. A consumer
|
|
43
|
+
can pass a short `items` array with the true `itemCount`; the remaining count stays explicit
|
|
44
|
+
instead of making one large pool determine the page height. Neither layout scrolls sideways.
|
|
45
|
+
|
|
46
|
+
### The three card shapes
|
|
47
|
+
|
|
48
|
+
Straight from the consumer requirement, which is specific because the owner answered *"which
|
|
49
|
+
row style?"* with **"all three, depending"**:
|
|
50
|
+
|
|
51
|
+
| The lane is | The card is |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| narrower than `cq-sm` (24rem) | **two lines** — title clamped to two, metadata underneath, trailing slot beside it |
|
|
54
|
+
| `cq-sm` to `cq-lg` | **one line** — title ellipsised, metadata right-aligned |
|
|
55
|
+
| `cq-lg` (48rem) and wider | **a card** — its own border, surface and elevation instead of a divider in a list |
|
|
56
|
+
|
|
57
|
+
It dissolved a bug rather than only satisfying a taste: a *fixed* two-line row collapsed its
|
|
58
|
+
title to `a…` inside a narrow lane, because the metadata beside it could not shrink. A card
|
|
59
|
+
sized by its container has no such state to be in.
|
|
60
|
+
|
|
61
|
+
### The wrappers are load-bearing
|
|
62
|
+
|
|
63
|
+
A container query matches **descendants only**, never the element that declares the
|
|
64
|
+
container. So the lane's panel cannot be the container *and* take its own frame off at
|
|
65
|
+
`cq-lg`; the `@container` sits on a wrapper `<div>` and the panel inside it does the
|
|
66
|
+
querying. Same reason `EmptyState` has one. Written on one element it compiles, generates
|
|
67
|
+
real CSS, and silently never fires — which is why `sourceRules.test.ts` fails on it.
|
|
68
|
+
|
|
69
|
+
## Moving a card, and the drag-and-drop decision
|
|
70
|
+
|
|
71
|
+
**No DnD library is taken as a dependency.** The full reasoning — licence, provenance, bundle
|
|
72
|
+
cost, and what a general DnD library would actually be buying for one card going into one
|
|
73
|
+
lane — is in
|
|
74
|
+
[the decision record](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-19-the-board-owns-the-move-and-takes-no-drag-and-drop-dependency.md).
|
|
75
|
+
|
|
76
|
+
The move is one control with two drivers, and they commit through the same `onMove`:
|
|
77
|
+
|
|
78
|
+
1. **A `Menu` on every card**, listing the other lanes. This is the **primary** path, not an
|
|
79
|
+
accessible alternative to a real one. It is the only one that works from the keyboard, the
|
|
80
|
+
only one a screen reader can drive, the only one that works on touch without a long-press
|
|
81
|
+
convention nobody discovers — and the only one available in the Narrow View, where the
|
|
82
|
+
other lanes are not on screen to drop onto.
|
|
83
|
+
2. **Pointer dragging from the same handle.** Pointer Events, so mouse, touch and pen are one
|
|
84
|
+
code path, with `setPointerCapture` so the drag survives the pointer leaving the card.
|
|
85
|
+
Escape abandons it.
|
|
86
|
+
|
|
87
|
+
An item can append actions to that existing menu with `menuItems`. The Board inserts a
|
|
88
|
+
separator after the lane destinations, so a card action does not need a second trigger.
|
|
89
|
+
|
|
90
|
+
Every move is announced in a `role="status"` region that names the **destination and the
|
|
91
|
+
position** — "Moved *X* to In Progress, position 3 of 6." That is the feedback a sighted user
|
|
92
|
+
gets free from watching the card land, and the thing almost every drag implementation forgets
|
|
93
|
+
to say out loud.
|
|
94
|
+
|
|
95
|
+
### Why not `draggable="true"`
|
|
96
|
+
|
|
97
|
+
The zero-dependency instinct, and the wrong one. HTML5 drag-and-drop does not fire on touch at
|
|
98
|
+
all, its drag image is a browser-drawn ghost with no styling hook worth using, and
|
|
99
|
+
`dataTransfer` is readable only inside a real `drop` — which makes a live drop indicator
|
|
100
|
+
awkward. Pointer Events cost the same (nothing) and cover every input.
|
|
101
|
+
|
|
102
|
+
### The move handle is a word by default
|
|
103
|
+
|
|
104
|
+
`Board` ships **no icon**, because a `⋮` renders as nothing where the font lacks it — this
|
|
105
|
+
sandbox's chromium, the kiosk image, the ePaper build
|
|
106
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-29-ship-no-icons-and-no-symbol-glyphs.md)).
|
|
107
|
+
An app that already owns a glyph set passes `moveIcon` and buys back ~35px a row.
|
|
108
|
+
|
|
109
|
+
### …and it takes the word back the moment a drag cannot work
|
|
110
|
+
|
|
111
|
+
`moveIcon` applies **while the lanes are side by side**. Under `cq-lg` the board is one lane
|
|
112
|
+
and a segmented control, there is nothing on screen to drop onto, and a grip glyph there
|
|
113
|
+
teaches the one gesture that cannot succeed. So the handle says **Move** again, which is the
|
|
114
|
+
gesture that does work: pressing it opens the same menu of the other lanes.
|
|
115
|
+
|
|
116
|
+
QueuePilot is the report behind this, from both directions. It shipped `≡` in a one-lane
|
|
117
|
+
board and the owner could not move anybody — *"There's no right-click or anything. How do I
|
|
118
|
+
move these?"* — and the first fix dropped the glyph at every width, which broke the wide
|
|
119
|
+
board where dragging is exactly what a person reaches for
|
|
120
|
+
([decision](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-08-27-the-move-handle-wears-the-gesture-that-can-succeed.md)).
|
|
121
|
+
|
|
122
|
+
Both affordances are in the DOM and CSS picks between them — no `ResizeObserver`, so the
|
|
123
|
+
first paint is right on a kiosk Pi. Both are `aria-hidden`, and the handle's whole
|
|
124
|
+
accessible name is a `VisuallyHidden` sentence beside them, so **the name is the same at
|
|
125
|
+
every width** and one `getByRole` query drives both layouts.
|
|
126
|
+
|
|
127
|
+
The query is against the **board's** container, which is named `board` for this one reason.
|
|
128
|
+
An unnamed `cq-lg:` inside a card asks the *lane*, and the lane answers backwards: a lane in
|
|
129
|
+
a three-up board is ~280px, and the Narrow View's single lane is the whole board.
|
|
130
|
+
|
|
131
|
+
## A lane heading can be a link
|
|
132
|
+
|
|
133
|
+
`BoardLane.href` makes the column title navigate — the "show me only this column" route a
|
|
134
|
+
board screen wants. It is **a link inside the heading, never a heading replaced by a
|
|
135
|
+
link**: the `<h3>` keeps the level the caller passed, keeps its id, and keeps naming the
|
|
136
|
+
lane's `group`, so the screen-reader outline of a linked board is the outline of an
|
|
137
|
+
unlinked one.
|
|
138
|
+
|
|
139
|
+
`label` stays a `string` rather than widening to a `ReactNode`, and that is the trade the
|
|
140
|
+
prop exists to avoid. The same value names the lane in the move menu on every card, in the
|
|
141
|
+
Narrow View's segmented control, in the "+ n more in Todo" line, and in the sentence the
|
|
142
|
+
live region reads after a move. None of those four can put a `ReactNode` in a string, so
|
|
143
|
+
widening `label` would buy one linkable heading at the cost of four places that could no
|
|
144
|
+
longer say which lane they mean.
|
|
145
|
+
|
|
146
|
+
The link inherits the heading's colour and weight. `TextLink` still supplies the cursor,
|
|
147
|
+
the focus ring and the hover underline, which is what says it is a link; a board whose
|
|
148
|
+
three column titles are all accent-coloured competes with the card titles underneath, and
|
|
149
|
+
those are what a reader is actually scanning. The `href` is routed through
|
|
150
|
+
`RouterLinkProvider` like every other one in this library, so an app with a client-side
|
|
151
|
+
router navigates without a full page load.
|
|
152
|
+
|
|
153
|
+
An app that was putting a link in `actions` as a stopgap can take it out.
|
|
154
|
+
|
|
155
|
+
**No `onMove` means read-only**, all or nothing: no handles, no menus, no drag. A per-card
|
|
156
|
+
`isMovable` would put the decision in the data, where a card that cannot move looks identical
|
|
157
|
+
to one nobody has thought about.
|
|
158
|
+
|
|
159
|
+
## Where the line is drawn
|
|
160
|
+
|
|
161
|
+
`Board` owns lanes, counts, truncation, empty states and the move. It does **not** own:
|
|
162
|
+
|
|
163
|
+
| Not here | Because |
|
|
164
|
+
| --- | --- |
|
|
165
|
+
| **Data** | It is a view of a list the consumer owns. `onMove` hands back a `fromIndex`/`toIndex` pair; the consumer splices. |
|
|
166
|
+
| **Virtualisation** | A lane truncates by construction — `itemCount` is the true total, `items` is what you chose to paint, and the difference becomes "+ n more". *"Long lanes truncate with an honest `+ n more` rather than scrolling forever."* There is nothing left to window. |
|
|
167
|
+
| **The cross-lane "needs attention" panel** | It reaches across every lane, so it is not a lane; it is absent when empty, so the board cannot reserve room for it; and it is already `Alert`. Composing it keeps `Board` about lanes and keeps the banner reusable above a list that is not a board. |
|
|
168
|
+
| **Sorting and filtering** | Both are operations on the array you pass in. |
|
|
169
|
+
|
|
170
|
+
That story is the copy-wholesale template: a page heading, an `Alert` for what needs
|
|
171
|
+
attention, and the board under it with `headingLevel={2}` so the outline stays whole.
|
|
172
|
+
|
|
173
|
+
## `toIndex` is already corrected for the removal
|
|
174
|
+
|
|
175
|
+
The most common bug in a hand-rolled board, folded into the component instead:
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
No arithmetic. A within-lane move quoted against the un-spliced list is one too high for every
|
|
180
|
+
position below the origin, so the component subtracts it once, in
|
|
181
|
+
[`toSettledIndex`](https://github.com/Sawtaytoes/charcuterie/blob/master/packages/ui/src/Board/boardMove.ts),
|
|
182
|
+
which is unit-tested in Node against fixtures — including the tie where a card dropped back on
|
|
183
|
+
its own midpoint must be **no move at all**.
|
|
184
|
+
|
|
185
|
+
## Accessibility
|
|
186
|
+
|
|
187
|
+
- The board is a **named landmark**; each lane is a `role="group"`, not a second landmark. A
|
|
188
|
+
board with four `region`s buries the page's real ones, and two boards on one page put two
|
|
189
|
+
landmarks called "Todo" in the document. Same call the
|
|
190
|
+
[accordion panel](https://github.com/Sawtaytoes/charcuterie/blob/master/docs/decisions/2026-07-31-an-accordion-panel-is-a-group-not-a-landmark.md)
|
|
191
|
+
made. It is a `<div role="group">` rather than a `<section role="group">` because axe's
|
|
192
|
+
`landmark-unique` matches `section[aria-labelledby]` on the element and audits it as a
|
|
193
|
+
landmark even after the role is overridden.
|
|
194
|
+
- **The priority bar's meaning is in words.** `accentIntent` paints it; `accentLabel` puts the
|
|
195
|
+
same fact in a `VisuallyHidden`, because colour alone fails WCAG 1.4.1 and is invisible to
|
|
196
|
+
every screen reader. Do the same for anything you put in `marks` — a bare coloured dot is
|
|
197
|
+
the identical failure.
|
|
198
|
+
- **`headingLevel` is yours.** Only the caller knows what the board sits under; an `<h3>`
|
|
199
|
+
directly below the page `<h1>` is an axe `heading-order` failure.
|
|
200
|
+
- Every move handle's accessible name says *which* card and *where it is now*. Thirty controls
|
|
201
|
+
named "Move" are thirty indistinguishable buttons to a screen reader and to
|
|
202
|
+
`getByRole("button", { name })`.
|
|
203
|
+
|
|
204
|
+
## Never invent a token name
|
|
205
|
+
|
|
206
|
+
The colour families here are `--color-intent-<intent>-<role>`, plus `surface`, `content` and
|
|
207
|
+
`border`. **There is no numeric scale.** Docket's first board painted every priority bar with
|
|
208
|
+
`--color-danger-9`, a Radix-style name this token set has never had, so every bar was
|
|
209
|
+
transparent — while every "is it rendered" assertion passed and only looking at the image
|
|
210
|
+
caught it. `accentIntent` is typed as `IntentName` for exactly that reason: a wrong value is a
|
|
211
|
+
compile error rather than an invisible rectangle.
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
<Board label="Project board" lanes={[
|
|
215
|
+
{ key: "todo", label: "To do", items: [] },
|
|
216
|
+
{ key: "done", label: "Done", items: [] },
|
|
217
|
+
]} />
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Published TypeScript API
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
const Board: ({ className, headingLevel, label, laneLayout, lanes, moveIcon, narrowLaneKey, onMove, }: BoardProps) => ReactNode
|
|
224
|
+
|
|
225
|
+
type BoardProps = {
|
|
226
|
+
className?: string;
|
|
227
|
+
/**
|
|
228
|
+
* What level the lane headings are. The caller's, because only the
|
|
229
|
+
* caller knows what the board sits under: a board directly below a
|
|
230
|
+
* page `<h1>` wants `2`, and one inside an already-deep section
|
|
231
|
+
* wants `4`. Getting it wrong is an axe `heading-order` failure and
|
|
232
|
+
* a broken screen-reader outline.
|
|
233
|
+
*/
|
|
234
|
+
headingLevel?: 2 | 3 | 4 | 5;
|
|
235
|
+
/** The board's accessible name. Required — it is a landmark. */
|
|
236
|
+
label: string;
|
|
237
|
+
/**
|
|
238
|
+
* How the lanes themselves are arranged.
|
|
239
|
+
*
|
|
240
|
+
* `columns` is the workflow shape: lanes sit side by side above
|
|
241
|
+
* `cq-lg`, and the Narrow View selects one lane. `rows` is the
|
|
242
|
+
* project-pool shape: every lane is one horizontal band, its cards
|
|
243
|
+
* form a responsive grid inside that band, and every lane stays on
|
|
244
|
+
* screen at every width.
|
|
245
|
+
*/
|
|
246
|
+
laneLayout?: "columns" | "rows";
|
|
247
|
+
lanes: readonly BoardLane[];
|
|
248
|
+
/**
|
|
249
|
+
* What the move handle shows **while the lanes are side by side**.
|
|
250
|
+
* Below `cq-lg` the handle says "Move" whatever this is, because
|
|
251
|
+
* there is nowhere to drag to — see `BoardCard`.
|
|
252
|
+
*
|
|
253
|
+
* The library ships no icons and no symbol glyphs in a default —
|
|
254
|
+
* they render as nothing where the font lacks them, which
|
|
255
|
+
* includes this sandbox's chromium, the kiosk image and the
|
|
256
|
+
* ePaper build — so the default is a word and an app that owns a
|
|
257
|
+
* glyph set passes one. On a dense board it is worth ~35px a row.
|
|
258
|
+
*/
|
|
259
|
+
moveIcon?: ReactNode;
|
|
260
|
+
/**
|
|
261
|
+
* Which lane is on screen below `cq-lg`. **Initial only** — the
|
|
262
|
+
* segmented control owns it from then on, matching every other
|
|
263
|
+
* uncontrolled control in this library.
|
|
264
|
+
*/
|
|
265
|
+
narrowLaneKey?: string;
|
|
266
|
+
/**
|
|
267
|
+
* The one thing that makes a board a board. **Absent means
|
|
268
|
+
* read-only**: no handles, no menus, no drag, and nothing
|
|
269
|
+
* announcing itself. A board with no `onMove` is a legitimate
|
|
270
|
+
* thing — a dashboard, an ePaper render — and it should not be
|
|
271
|
+
* carrying affordances that do nothing.
|
|
272
|
+
*/
|
|
273
|
+
onMove?: (move: BoardMove) => void;
|
|
274
|
+
};
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
[Full declarations](../../dist/Board/Board.d.ts)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Breadcrumbs
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Breadcrumbs } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A path back up a hierarchy: `Places › Office › Office Shelves`.
|
|
8
|
+
|
|
9
|
+
Folio, image-viewer and mux-magic each hand-rolled one, and no two agreed on the landmark,
|
|
10
|
+
the list, the current page or what happens to a long name. This is the WAI-ARIA APG
|
|
11
|
+
breadcrumb pattern — a named `<nav>` around an `<ol>` — with the link paint of `TextLink`.
|
|
12
|
+
|
|
13
|
+
## What each rung becomes
|
|
14
|
+
|
|
15
|
+
A rung is read off the fields it carries. The caller says where it goes, never what it is.
|
|
16
|
+
|
|
17
|
+
| Item | Renders | Use it for |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| `{ label, href }` | a `TextLink` — a real `<a href>`, routed through `RouterLinkProvider` | a trail over URLs: Folio, Whereabouts |
|
|
20
|
+
| `{ label, onSelect }` | a `<button>` painted as the same link | a trail over state with no URL: image-viewer's folders, mux-magic's file explorer |
|
|
21
|
+
| `{ label }`, last | text with `aria-current="page"` | the current page |
|
|
22
|
+
| `{ label }`, not last | plain text | a level that has no page of its own |
|
|
23
|
+
|
|
24
|
+
`href` and `onSelect` together render the link and run `onSelect` on click as well.
|
|
25
|
+
|
|
26
|
+
## A trail above a heading has no current rung
|
|
27
|
+
|
|
28
|
+
When the page already names itself in a heading, the trail stops at the parent and every
|
|
29
|
+
rung is a link. Nothing gets `aria-current`, because the heading is the current page's
|
|
30
|
+
name and it should be announced once.
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## It wraps, and it never truncates
|
|
35
|
+
|
|
36
|
+
A long trail wraps between rungs, and a rung with no spaces breaks inside itself. Nothing
|
|
37
|
+
is cut to `Office Sh…`: the word that would be cut is the one the reader came to find.
|
|
38
|
+
|
|
39
|
+
## The separator
|
|
40
|
+
|
|
41
|
+
The default is a chevron drawn in CSS borders, not a `›` character — the library ships no
|
|
42
|
+
symbol glyphs in a default, because a font that lacks one paints nothing. It points the
|
|
43
|
+
way the trail reads in a right-to-left page too. Pass `separator` to use your own; it is
|
|
44
|
+
always `aria-hidden`.
|
|
45
|
+
|
|
46
|
+
## Keyboard
|
|
47
|
+
|
|
48
|
+
Tab walks the rungs in order. Enter follows a link; Enter or Space presses a button rung.
|
|
49
|
+
The current page is text, so Tab skips it.
|
|
50
|
+
|
|
51
|
+
## Example from the stories
|
|
52
|
+
|
|
53
|
+
See the full [story example](../../src/Breadcrumbs/Breadcrumbs.stories.tsx).
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<Breadcrumbs
|
|
57
|
+
items={[{ label: "Library" }]}
|
|
58
|
+
label="Root trail"
|
|
59
|
+
/>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Published TypeScript API
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const Breadcrumbs: ({ className, items, label, separator, }: BreadcrumbsProps) => ReactNode
|
|
66
|
+
|
|
67
|
+
type BreadcrumbsProps = {
|
|
68
|
+
className?: string;
|
|
69
|
+
items: readonly BreadcrumbItem[];
|
|
70
|
+
/**
|
|
71
|
+
* The `<nav>` landmark's name. Two trails on one page need two
|
|
72
|
+
* different names, or axe's `landmark-unique` fails.
|
|
73
|
+
*/
|
|
74
|
+
label?: string;
|
|
75
|
+
/**
|
|
76
|
+
* Drawn between rungs, always `aria-hidden`. The default is a
|
|
77
|
+
* chevron drawn in CSS borders rather than a `›` character: the
|
|
78
|
+
* library ships no symbol glyphs in a default, because a font that
|
|
79
|
+
* lacks one paints nothing
|
|
80
|
+
* (`docs/decisions/2026-07-29-ship-no-icons-and-no-symbol-glyphs.md`).
|
|
81
|
+
* Folio's `/` is a fine override — it is the app's choice to make.
|
|
82
|
+
*/
|
|
83
|
+
separator?: ReactNode;
|
|
84
|
+
};
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
[Full declarations](../../dist/Breadcrumbs/Breadcrumbs.d.ts)
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Button } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Hand-rolled in **seven repos**, each with its own primary/secondary/danger/ghost pair and
|
|
8
|
+
its own idea of what "disabled" looks like. This is the single largest duplication in the
|
|
9
|
+
fleet.
|
|
10
|
+
|
|
11
|
+
Six intents x four appearances x three sizes, all of it from tier-2 tokens — so a variant
|
|
12
|
+
swap or a density flip repaints every button on the page with no prop change and no
|
|
13
|
+
re-render.
|
|
14
|
+
|
|
15
|
+
## What it fixes
|
|
16
|
+
|
|
17
|
+
| Fleet behaviour today | Here |
|
|
18
|
+
| --- | --- |
|
|
19
|
+
| `<button>` with no `type`, submitting the form it happens to sit in | `type="button"` by default |
|
|
20
|
+
| `outline-none` with nothing put back, or a ring on mouse click | `focus-visible` only, at the variant's own ring width |
|
|
21
|
+
| A spinner that replaces the label, so you cannot tell what you pressed | Spinner replaces `iconStart`; the label stays, `aria-busy` goes on |
|
|
22
|
+
| A `size="kiosk"` prop, or a second component for touch | `data-density="kiosk"` on `<html>` |
|
|
23
|
+
|
|
24
|
+
## Accessibility contract
|
|
25
|
+
|
|
26
|
+
- The accessible name is the children. A glyph is not a name — use `IconButton`, which
|
|
27
|
+
requires one.
|
|
28
|
+
- `isLoading` disables the button and announces through the `Spinner`'s `role="status"`.
|
|
29
|
+
- `isDisabled` renders a real `disabled` attribute: skipped by Tab, ignored by click, and
|
|
30
|
+
reported to assistive technology. The `DisabledDoesNotFire` story asserts all three.
|
|
31
|
+
- Contrast on the disabled treatment leans on WCAG 1.4.3's exemption for *inactive*
|
|
32
|
+
controls, which is honest only on something actually disabled — see `DISABLED_CLASS`.
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
function SaveButton({ save, isSaving }: { save: () => void; isSaving: boolean }) {
|
|
36
|
+
return <Button intent="accent" isLoading={isSaving} onClick={save}>Save changes</Button>
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Published TypeScript API
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const Button: ({ appearance, children, className, iconEnd, iconStart, intent, isDisabled, isFullWidth, isLoading, loadingLabel, size, sizing, type, ...buttonProps }: ButtonProps) => ReactNode
|
|
44
|
+
|
|
45
|
+
type ButtonProps = Omit<ComponentPropsWithRef<"button">, "disabled"> & {
|
|
46
|
+
appearance?: IntentAppearance;
|
|
47
|
+
iconEnd?: ReactNode;
|
|
48
|
+
iconStart?: ReactNode;
|
|
49
|
+
intent?: IntentName;
|
|
50
|
+
isDisabled?: boolean;
|
|
51
|
+
isFullWidth?: boolean;
|
|
52
|
+
isLoading?: boolean;
|
|
53
|
+
/** What the spinner announces. Not shown. */
|
|
54
|
+
loadingLabel?: string;
|
|
55
|
+
size?: ControlSize;
|
|
56
|
+
/**
|
|
57
|
+
* Two sizing modes rather than a second component's worth of
|
|
58
|
+
* markup. `icon` is square on the control height with no inline
|
|
59
|
+
* padding, which is what lines an `IconButton` up with the text
|
|
60
|
+
* button beside it in a toolbar.
|
|
61
|
+
*
|
|
62
|
+
* It lives here rather than in `IconButton` because appending a
|
|
63
|
+
* competing `size-*`/`px-0` to this component's `className` would
|
|
64
|
+
* be a specificity coin-flip: two utilities setting the same
|
|
65
|
+
* property, and the winner decided by Tailwind's internal
|
|
66
|
+
* ordering rather than by the caller.
|
|
67
|
+
*/
|
|
68
|
+
sizing?: "control" | "icon";
|
|
69
|
+
};
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
[Full declarations](../../dist/Button/Button.d.ts)
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# ButtonLink
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ButtonLink } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
**Navigation that looks like a button.** It takes `Button`'s visual props and paints
|
|
8
|
+
identically to it — and it is an `<a href>`.
|
|
9
|
+
|
|
10
|
+
That combination is the whole component. Plex Channels' "Configure" reads as the primary
|
|
11
|
+
action on its card, so it has to look like a solid button; it goes to another page, so it
|
|
12
|
+
has to be a link. Today it is a `<button onClick={() => navigate("#/settings")}>`, which
|
|
13
|
+
cannot be middle-clicked, ctrl-clicked, opened in a new tab, or copied — and mux-magic
|
|
14
|
+
solves the same problem in the other direction, with 14 raw `<a href="/…">` that force a
|
|
15
|
+
full page reload through its own SPA router.
|
|
16
|
+
|
|
17
|
+
## It is the same paint, not a copy of it
|
|
18
|
+
|
|
19
|
+
`Button` and `ButtonLink` both assemble their class list through `getControlClassName`, so
|
|
20
|
+
`INTENT_APPEARANCE_CLASS`, `CONTROL_SIZE_CLASS`, and `FOCUS_RING_CLASS` are read once
|
|
21
|
+
rather than duplicated. `ButtonLink.test.tsx` then compares the two elements' **computed**
|
|
22
|
+
styles in the real browser, which is the version of that claim a refactor cannot quietly
|
|
23
|
+
break.
|
|
24
|
+
|
|
25
|
+
## Three things `Button` has that this does not
|
|
26
|
+
|
|
27
|
+
| Missing | Why |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `isLoading` | A navigation has no pending state **this component** owns. The wait belongs to the destination — a router transition, a `Suspense` boundary, a `ProgressBar` on the page being entered. A spinner here would be the component lying about work it is not doing. |
|
|
30
|
+
| `type` | There is no form to submit. |
|
|
31
|
+
| `sizing="icon"` | An icon-only navigation is an `IconButton` problem — a glyph is not an accessible name — and solving it here would mean a second name-enforcing type. |
|
|
32
|
+
|
|
33
|
+
## Accessibility contract
|
|
34
|
+
|
|
35
|
+
- The accessible name is the children. `iconStart`/`iconEnd` are decoration inside the same
|
|
36
|
+
anchor.
|
|
37
|
+
- `isDisabled` **drops `href`** and sets `aria-disabled` with an explicit `role="link"`,
|
|
38
|
+
rather than shipping a focusable `<a>` that silently ignores clicks. It is painted
|
|
39
|
+
through `ARIA_DISABLED_CLASS`, which also switches off pointer events — without a real
|
|
40
|
+
`:disabled`, CSS `:hover` still matches, so the hover fill has to be taken off the table
|
|
41
|
+
rather than merely overridden.
|
|
42
|
+
- `isExternal` sets `target="_blank"`, `rel="noopener noreferrer"`, and a visually-hidden
|
|
43
|
+
*"(opens in a new tab)"*.
|
|
44
|
+
- Contrast on the disabled treatment leans on WCAG 1.4.3's exemption for *inactive*
|
|
45
|
+
controls, exactly as `Button`'s does.
|
|
46
|
+
|
|
47
|
+
## Routing
|
|
48
|
+
|
|
49
|
+
`ButtonLink` renders through whatever link component the app injected at its root, and a
|
|
50
|
+
plain `<a>` when nothing is injected — or when the destination is external or a fragment,
|
|
51
|
+
which no router should intercept. See **Guides/Routing**.
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
<ButtonLink href="/projects/new" intent="accent">New project</ButtonLink>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Published TypeScript API
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
const ButtonLink: ({ appearance, children, className, href, iconEnd, iconStart, intent, isDisabled, isExternal, isFullWidth, newTabLabel, size, ...anchorProps }: ButtonLinkProps) => ReactNode
|
|
61
|
+
|
|
62
|
+
type ButtonLinkProps = Omit<ComponentPropsWithRef<"a">, "href"> & {
|
|
63
|
+
appearance?: IntentAppearance;
|
|
64
|
+
/**
|
|
65
|
+
* Required, and required even when disabled — a navigation that
|
|
66
|
+
* cannot say where it goes is a button wearing a link's clothes.
|
|
67
|
+
*/
|
|
68
|
+
href: string;
|
|
69
|
+
iconEnd?: ReactNode;
|
|
70
|
+
iconStart?: ReactNode;
|
|
71
|
+
intent?: IntentName;
|
|
72
|
+
isDisabled?: boolean;
|
|
73
|
+
isExternal?: boolean;
|
|
74
|
+
isFullWidth?: boolean;
|
|
75
|
+
/** What `isExternal` announces. Not shown. */
|
|
76
|
+
newTabLabel?: string;
|
|
77
|
+
size?: ControlSize;
|
|
78
|
+
};
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
[Full declarations](../../dist/ButtonLink/ButtonLink.d.ts)
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# Card
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Card } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Five repos, and the reason it is P0 is the `<section>`: give a card a heading and it becomes
|
|
8
|
+
a **landmark**, so `getByRole("region", { name: "Bay 3" })` scopes every query inside it.
|
|
9
|
+
Without that, an agent driving a 16-bay tower sees sixteen identical "Start" buttons and no
|
|
10
|
+
way to say which one it means. The `Interactive` story asserts exactly that.
|
|
11
|
+
|
|
12
|
+
## Density is not a prop
|
|
13
|
+
|
|
14
|
+
The withdrawn bambuddy evidence included a `CardDensityProvider`, and it is the wrong shape
|
|
15
|
+
for this fleet: density is a global axis on `<html>`, so a compact bay list is
|
|
16
|
+
`data-density="compact"` on the page rather than a context around the cards. `padding`
|
|
17
|
+
stays a prop because a card wrapping a poster grid genuinely has none — a layout fact, not
|
|
18
|
+
a density one.
|
|
19
|
+
|
|
20
|
+
## Names must be unique
|
|
21
|
+
|
|
22
|
+
Two `<section>`s sharing an accessible name is axe's `landmark-unique`, and it is a real
|
|
23
|
+
finding rather than a technicality: a screen-reader user navigating by landmark gets two
|
|
24
|
+
"Bay 3" regions and no way to tell them apart. A card with no heading is not a landmark at
|
|
25
|
+
all, deliberately — it has nothing to be named.
|
|
26
|
+
|
|
27
|
+
`raised` means *more separated from base*, not *lighter*, which is why light mode's base is
|
|
28
|
+
`#F5F7FA` and its raised is white.
|
|
29
|
+
|
|
30
|
+
### A card the app names itself
|
|
31
|
+
|
|
32
|
+
Pass `aria-labelledby` and no `heading` when the app draws its own title row — a name beside
|
|
33
|
+
a count is one line that `heading` cannot express, so mail-sifter's tiles render it and point
|
|
34
|
+
at it. The card keeps that pointer.
|
|
35
|
+
|
|
36
|
+
> **It has to be a fallback, not a default.** The attribute is written after the caller's
|
|
37
|
+
> props are spread, so the obvious `heading ? headingId : undefined` **overwrites** the call
|
|
38
|
+
> site's pointer rather than leaving it alone. React then drops the attribute, the card's name
|
|
39
|
+
> falls back to its entire subtree, and nothing reports it: the markup is valid, the types are
|
|
40
|
+
> satisfied, and axe is content with a name made of everything. Both of mail-sifter's
|
|
41
|
+
> `role="button"` tiles announced their whole contents — "Recent Mail 6 40 arrived in the last
|
|
42
|
+
> 24 hours, 34 done" for a tile called "Recent Mail".
|
|
43
|
+
|
|
44
|
+
`heading` still wins where both are given, because the heading is text the reader can see and
|
|
45
|
+
this component renders it. `aria-label` needs no fallback at all — `Card` never writes one, so
|
|
46
|
+
the spread carries the caller's through.
|
|
47
|
+
|
|
48
|
+
## Container queries, not media queries
|
|
49
|
+
|
|
50
|
+
> **One constraint that comes with the territory.** `container-type: inline-size` implies
|
|
51
|
+
> `contain: inline-size`, so a `Card` may not be sized by its own contents. In a grid track,
|
|
52
|
+
> a block flow, or a `flex-1` slot it is fine — that is nearly every real placement. Drop one
|
|
53
|
+
> into a shrink-to-fit parent (`items-start`, an `inline-flex` row) and it collapses to
|
|
54
|
+
> min-content, wrapping every line after one word. Give it a definite inline size there.
|
|
55
|
+
|
|
56
|
+
The header stacks below `--cq-sm` and sits on one row above it, and the container is the
|
|
57
|
+
**card**. The same card in a sidebar and full-bleed on a dashboard is the case a media query
|
|
58
|
+
cannot tell apart, and it is where the fleet's poster grids look wrong today.
|
|
59
|
+
|
|
60
|
+
## The accent edge follows the corner
|
|
61
|
+
|
|
62
|
+
`accentEdge` draws a coloured bar down the leading edge. `{ categorical: 3 }` is a colour a
|
|
63
|
+
user picked, from the ten-wide contrast-audited family; `{ color }` is one the app computed,
|
|
64
|
+
for the case where ten indices are not enough — Folio hashes a repo's name so a repo added
|
|
65
|
+
tomorrow already has a hue and nobody maintains a palette.
|
|
66
|
+
|
|
67
|
+
> **It is a pseudo-element, not a border, and that is the whole point.** Three apps grew this
|
|
68
|
+
> shape independently and all three drew a straight border beside a rounded box, so the bar
|
|
69
|
+
> ran past the curve and stopped square while the card was round. A border is painted on the
|
|
70
|
+
> border box; it cannot follow a corner. The overlay here takes `border-radius: inherit`, so
|
|
71
|
+
> the bar reads the radius off whatever card it is on and nobody states one twice.
|
|
72
|
+
|
|
73
|
+
Two shapes this deliberately is not. **Not `box-shadow: inset` on the card itself** — `Card`
|
|
74
|
+
carries `shadow-low` from the elevation scale, and a `box-shadow` at the call site outranks
|
|
75
|
+
that utility and takes the elevation with it. **Not a 3px-wide pseudo-element with a rounded
|
|
76
|
+
leading edge** — a `0.5rem` radius on a 3px box is clamped to fit, so it caps the bar instead
|
|
77
|
+
of following the curve.
|
|
78
|
+
|
|
79
|
+
## Example from the stories
|
|
80
|
+
|
|
81
|
+
See the full [story example](../../src/Card/Card.stories.tsx).
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
<Card heading="Bay 1" />
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Published TypeScript API
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
const Card: ({ "aria-labelledby": ariaLabelledBy, accentEdge, actions, children, className, elevation, footer, heading, headingLevel, padding, style, surface, ...sectionProps }: CardProps) => ReactNode
|
|
91
|
+
|
|
92
|
+
type CardProps = ComponentPropsWithRef<"section"> & {
|
|
93
|
+
/**
|
|
94
|
+
* A coloured bar down the leading edge, following the card's own
|
|
95
|
+
* corners.
|
|
96
|
+
*
|
|
97
|
+
* `{ categorical: 3 }` for a colour a user picked; `{ color }`
|
|
98
|
+
* for one an app computed — a hue hashed from a repo's name, say,
|
|
99
|
+
* where ten indices are not enough. See `cardAccentEdge.ts` for
|
|
100
|
+
* why it is a pseudo-element and not a border.
|
|
101
|
+
*/
|
|
102
|
+
accentEdge?: CardAccentEdge;
|
|
103
|
+
/** Buttons or a badge, laid out beside the heading. */
|
|
104
|
+
actions?: ReactNode;
|
|
105
|
+
elevation?: ElevationStep;
|
|
106
|
+
footer?: ReactNode;
|
|
107
|
+
heading?: string;
|
|
108
|
+
headingLevel?: 2 | 3 | 4;
|
|
109
|
+
padding?: CardPadding;
|
|
110
|
+
surface?: CardSurface;
|
|
111
|
+
};
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
[Full declarations](../../dist/Card/Card.d.ts)
|