@charcuterie/ui 4.29.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/dist/CatalogPicker/CatalogPicker.d.ts +7 -2
- package/dist/CatalogPicker/CatalogPicker.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPicker.js +6 -3
- package/dist/CatalogPicker/CatalogPicker.js.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.d.ts.map +1 -1
- package/dist/CatalogPicker/CatalogPickerOption.js +5 -4
- package/dist/CatalogPicker/CatalogPickerOption.js.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts +13 -1
- package/dist/CatalogPicker/catalogPickerView.d.ts.map +1 -1
- package/dist/CatalogPicker/catalogPickerView.js +10 -0
- package/dist/CatalogPicker/catalogPickerView.js.map +1 -1
- 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/CatalogPicker/CatalogPicker.mdx +36 -1
- package/src/CatalogPicker/CatalogPicker.test.tsx +264 -24
- package/src/CatalogPicker/CatalogPicker.tsx +14 -3
- package/src/CatalogPicker/CatalogPickerOption.tsx +19 -6
- package/src/CatalogPicker/catalogPickerView.test.ts +19 -0
- package/src/CatalogPicker/catalogPickerView.ts +20 -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,231 @@
|
|
|
1
|
+
# Build a screen with Charcuterie
|
|
2
|
+
|
|
3
|
+
## The component-choice table
|
|
4
|
+
|
|
5
|
+
Start here. Find the row that matches what you are about to build.
|
|
6
|
+
|
|
7
|
+
| You want to… | Use | Never |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Send the user somewhere, inline in a sentence or as a standalone link | [`TextLink`](components/TextLink.md) (`appearance="inline"` or `"standalone"`) | `<a>`; `<button onClick={navigate}>`; a clickable `<div>` |
|
|
10
|
+
| Send the user somewhere, but it should *look* like a button | [`ButtonLink`](components/ButtonLink.md) — a real `<a href>` painted as a button | [`Button`](components/Button.md) with an `onClick` that navigates |
|
|
11
|
+
| Preserve an established app-owned link treatment while adding soft navigation | [`UnstyledLink`](components/UnstyledLink.md) — the router seam with no paint of its own | Replacing the app's appearance with [`TextLink`](components/TextLink.md); calling `useNavigate` from a click handler |
|
|
12
|
+
| Do something on this page — submit, open, retry, delete | [`Button`](components/Button.md) | `<button>`; a `<div onClick>` |
|
|
13
|
+
| Do something on this page, and the control is icon-only | [`IconButton`](components/IconButton.md) — `label` is **required** | [`Button`](components/Button.md) with only a glyph inside |
|
|
14
|
+
| Offer two or three ways forward, each needing a sentence to explain it | [`ActionTiles`](components/ActionTiles.md) — a set of pressable or linking tiles | a [`Button`](components/Button.md) with `height: auto` (a [`Button`](components/Button.md) has **no** block padding; the override leaves `padding: 0` and a title flush against the border) |
|
|
15
|
+
| The same tiles, but one stays chosen and something below reads the value | `RadioGroup itemShape="tile"` | [`ActionTiles`](components/ActionTiles.md) plus your own selected state; a `<div>` of `aria-pressed` buttons |
|
|
16
|
+
| Pick one of a handful of options | [`Picker`](components/Picker.md) — a [`Listbox`](components/Listbox.md) with the trigger attached | [`Select`](components/Select.md); a hand-rolled `role="listbox"`; a raw `<select>` |
|
|
17
|
+
| Pick one, but the trigger is a tile, a table header, something that is not a button | [`Listbox`](components/Listbox.md) | wrapping [`Picker`](components/Picker.md) in something that is not a button |
|
|
18
|
+
| Pick from many, or the user should be able to type to find it | [`Combobox`](components/Combobox.md) (`isMultiple` for multi-select) | a `<select>` with 400 `<option>` |
|
|
19
|
+
| Pick one from a large catalog that falls into groups — AI models by provider and account | [`CatalogPicker`](components/CatalogPicker.md) — a rail of groups (Favorites first), a search across every group, `groups` / `items` / `favorites` | a [`Picker`](components/Picker.md) of 40 rows reading "Provider · Model · slug"; a [`Combobox`](components/Combobox.md) whose labels repeat the group name |
|
|
20
|
+
| Take a position in a piece of media — a resume point, a clip boundary | [`TimecodeInput`](components/TimecodeInput.md) (`isRange` for a section, both ends optional) | `<input type="time">` (a 24-hour wall clock, no milliseconds, OS-painted); a sixth hand-rolled `h:mm:ss` formatter |
|
|
21
|
+
| Pick a **span** — a clip's start and end, a price band, a section of a timeline | [`RangeSlider`](components/RangeSlider.md) — two `role="slider"` thumbs in a group, with `valueFormat` for the units | two [`Slider`](components/Slider.md)s side by side; `<input type="range">`; a pair of number fields called a range |
|
|
22
|
+
| Label, describe or error-annotate any control | [`Field`](components/Field.md) | a bare `<label>` + hand-wired `aria-describedby` |
|
|
23
|
+
| Page chrome — header, rails, the content column | [`Shell`](components/Shell.md) / [`Header`](components/Header.md) / [`Rail`](components/Rail.md) / [`Main`](components/Main.md) | a new `AppShell.tsx` |
|
|
24
|
+
| The sections of ONE screen, each with its own address | [`Tabs`](components/Tabs.md) with `href` items + `activeHref` | a [`Nav`](components/Nav.md) (that is the app's destinations, and its current item is a pill); a [`Tabs`](components/Tabs.md) whose choice is state, so reload and Back lose the section |
|
|
25
|
+
| The path back up a hierarchy (`Places › Office › Office Shelves`) | [`Breadcrumbs`](components/Breadcrumbs.md) — `href` rungs for URLs, `onSelect` rungs for state with no URL | a `<div>` of links and `/` spans; a `truncate` on the current segment; a `›` glyph the font may lack |
|
|
26
|
+
| A thing's secondary actions behind one vertical-dots button | [`ActionMenu`](components/ActionMenu.md) — `items`, and a `label` naming the thing (`Actions for Cables`) | an [`IconButton`](components/IconButton.md) + [`Menu`](components/Menu.md) + `useState` wired by hand; a `⋮` character; a trigger named only "More" |
|
|
27
|
+
| A launcher or quick switcher over the whole app — `Ctrl K`, a list before typing, a web-search last row | [`CommandPalette`](components/CommandPalette.md) + `useCommandPalette()` — `suggestions`, `items`, `prefixes`, `getFallbackItem` | a [`Combobox`](components/Combobox.md) in a [`Dialog`](components/Dialog.md); a document `keydown` listener in a component; a search box that shows nothing until you type |
|
|
28
|
+
| The app's destinations, wherever they sit, and how they collapse | [`Nav`](components/Nav.md) + `useNavLayout` | [`NavBar`](components/NavBar.md) (deprecated); a [`Toolbar`](components/Toolbar.md) of `onSelect` items; a row of `NavLink`s and a `flex-wrap` in your own stylesheet; the same nav rendered twice behind `hidden md:flex` |
|
|
29
|
+
| Rows of text under group headings — pages by screen, cards by owner — each with a muted line, badges and a trailing button | [`GroupedList`](components/GroupedList.md) — `groups` of `items`; the app keeps the search and the grouping | `<section>` + `<h3>` + `<ul>` by hand; one named `<section>` landmark per group |
|
|
30
|
+
| A grid of cards that should reflow | [`AdaptiveGrid`](components/AdaptiveGrid.md) | `grid-cols-*` breakpoints; `auto-fill, minmax()` |
|
|
31
|
+
| Measurable work with a prominent value and supporting metrics | [`ProgressCard`](components/ProgressCard.md) | a custom progress-band card or CSS that reaches into [`ProgressBar`](components/ProgressBar.md) |
|
|
32
|
+
| Anything with a glyph in it | your own icon (lucide, ISC, is the fleet pick) | expecting the library to ship one |
|
|
33
|
+
|
|
34
|
+
## Library conventions
|
|
35
|
+
|
|
36
|
+
- Choose `Picker` for a short option list with a built-in trigger, `Listbox` for a custom trigger, and `Combobox` for a searchable list. Native `Select` is deprecated.
|
|
37
|
+
- The logic state hooks are uncontrolled. Options such as `isVisible`, `selectedValue`, and `activeValue` initialize state once. Call the returned commands to change state and pass `onChange` to observe intent changes.
|
|
38
|
+
- Use `colour` in TypeScript names and `--color-*` in CSS token names. Keep existing public spellings, such as `ColorSchemeSwitcher`.
|
|
39
|
+
- Keep dependencies going from UI to logic and tokens. Logic cannot import UI. Tokens stay dependency-free and React-free.
|
|
40
|
+
- The app ESLint preset includes picker rules. Set `componentChoice: "all"` to opt into the other component-choice rules and `flexOverflow: "warn"` to opt into flex-overflow rules. Apply both to app source.
|
|
41
|
+
|
|
42
|
+
## Wiring a new app
|
|
43
|
+
|
|
44
|
+
### 1. Install and import the stylesheets
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
pnpm add @charcuterie/ui @charcuterie/tokens
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
@import "tailwindcss";
|
|
52
|
+
@import "@charcuterie/tokens/theme.css"; /* colours, type ramp, radii, motion */
|
|
53
|
+
@import "@charcuterie/tokens/fonts.css"; /* Baloo 2, Outfit, Victor Mono */
|
|
54
|
+
@import "@charcuterie/ui/styles.css"; /* looping affordances + .charcuterie-scrollbar */
|
|
55
|
+
|
|
56
|
+
@source "../node_modules/@charcuterie/ui/dist";
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
**Both package names, and both of those last two lines, are load-bearing.**
|
|
60
|
+
|
|
61
|
+
- The token **stylesheet** is imported from `@charcuterie/tokens` **by its own package
|
|
62
|
+
name** — there is no `@charcuterie/ui/tokens.css`, on purpose. One used to exist, pointing
|
|
63
|
+
at `./node_modules/@charcuterie/tokens/dist/theme.css` inside `ui`, and it resolved to
|
|
64
|
+
nothing in the first real consumer: a hoisting linker puts `@charcuterie/tokens` at the
|
|
65
|
+
*project* root, not inside the dependency. A CSS `@import` that misses fails **silently**
|
|
66
|
+
in Tailwind — no error, no utilities, an unstyled app. The trap is written up in
|
|
67
|
+
`packages/ui/src/index.ts`'s docstring.
|
|
68
|
+
- The token **types and values** *are* re-exported, at `@charcuterie/ui/tokens`, so your
|
|
69
|
+
TypeScript only ever names one package.
|
|
70
|
+
- `@source` is not optional either. Tailwind v4 scans **source text** for complete class
|
|
71
|
+
strings and does not scan your dependencies — without that line every component renders
|
|
72
|
+
unstyled, again with no error.
|
|
73
|
+
|
|
74
|
+
Then copy the first-paint snippet into your HTML head, from `@charcuterie/tokens`'
|
|
75
|
+
`dist/first-paint.css`. It is a **copy-me file, never `<link>`ed** — a
|
|
76
|
+
stylesheet request is the round-trip it exists to beat — and it must stay a `var()` fallback,
|
|
77
|
+
because an inline `<style>` is unlayered and a flat hex there outranks every utility forever
|
|
78
|
+
and pins the canvas to one scheme.
|
|
79
|
+
|
|
80
|
+
**Light mode is not pure white.** `surface.base` is a warm or cool near-white, and `raised`
|
|
81
|
+
means *more separated from base*, not *lighter*. If you set base to `#FFFFFF`, `raised` has
|
|
82
|
+
nowhere left to go and every card in the app disappears into the page.
|
|
83
|
+
|
|
84
|
+
### 2. Wire the router
|
|
85
|
+
|
|
86
|
+
**One component at the app root**, inside the router:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { ReactRouterAdapter } from "@charcuterie/ui/react-router"
|
|
90
|
+
|
|
91
|
+
<BrowserRouter>
|
|
92
|
+
<ReactRouterAdapter>
|
|
93
|
+
<App />
|
|
94
|
+
</ReactRouterAdapter>
|
|
95
|
+
</BrowserRouter>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
That is two seams, and you want both.
|
|
99
|
+
|
|
100
|
+
**Links.** `TextLink` and `ButtonLink` already work with no setup — they render a real
|
|
101
|
+
anchor, they just reload the page. The adapter upgrades every link in the tree to soft
|
|
102
|
+
navigation, with no change at any call site. The seam is keyed on **`href`, not `to`** — each
|
|
103
|
+
adapter renames it on the way in — so any router is a four-line adapter in your own app.
|
|
104
|
+
|
|
105
|
+
**Scroll.** `Main` is your page's only vertical scrollport (step 4), and a browser restores
|
|
106
|
+
the **document** scroller, never an inner one — so Back lands at the top of a list the reader
|
|
107
|
+
had scrolled half-way down, in every browser, with no setting that changes it. The adapter
|
|
108
|
+
gives `Main` the history entry and the offset comes back. Skip this and the app is not
|
|
109
|
+
broken, it is just quietly worse, which is why it is one component and not a prop.
|
|
110
|
+
|
|
111
|
+
`react-router` is an *optional* peer dependency and the adapter is a separate entry point, so
|
|
112
|
+
an app that never imports it never resolves it. Full recipe, including `createBrowserRouter`,
|
|
113
|
+
wouter, hand-rolled routers, and the three destinations that always fall through to a plain
|
|
114
|
+
`<a>`: **Guides → Routing**.
|
|
115
|
+
|
|
116
|
+
### 3. Adopt the house lint config
|
|
117
|
+
|
|
118
|
+
```sh
|
|
119
|
+
pnpm add --dev @charcuterie/eslint-config eslint
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
// eslint.config.js — the whole file
|
|
124
|
+
import { createAppConfig } from "@charcuterie/eslint-config"
|
|
125
|
+
import { defineConfig } from "eslint/config"
|
|
126
|
+
|
|
127
|
+
export default defineConfig(
|
|
128
|
+
...createAppConfig({
|
|
129
|
+
tsconfigRootDir: import.meta.dirname,
|
|
130
|
+
// Where your own source lives. `["src"]` if you omit it.
|
|
131
|
+
appDirectories: ["packages/web"],
|
|
132
|
+
}),
|
|
133
|
+
)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```jsonc
|
|
137
|
+
// biome.json — an app extends both; the library extends the base alone
|
|
138
|
+
{
|
|
139
|
+
"extends": [
|
|
140
|
+
"@charcuterie/biome-config",
|
|
141
|
+
"@charcuterie/biome-config/app"
|
|
142
|
+
],
|
|
143
|
+
"files": { "includes": ["./**", "!**/dist"] }
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Both entries. `/app` is a **delta** carrying only the picker rules — Biome does not
|
|
148
|
+
resolve a nested `extends` inside an extended config, so a lone `/app` would hand you the
|
|
149
|
+
picker rules and Biome's stock formatter, silently.
|
|
150
|
+
|
|
151
|
+
That is the setup. `appDirectories` is the only thing you have to know, and it is the
|
|
152
|
+
scoping that keeps the component rules off `@charcuterie/ui` — which renders raw `<a>`,
|
|
153
|
+
`<button>` and `<select>` because rendering them correctly *is* the library.
|
|
154
|
+
|
|
155
|
+
Out of the box you get the type-aware house rules (`is`/`has` booleans, `id-length`), one
|
|
156
|
+
component per file, `test()` over `it()`, logical properties only, and **the picker
|
|
157
|
+
rules** — `charcuterie/no-raw-select` and `charcuterie/prefer-listbox-over-select`, on by
|
|
158
|
+
default because `Select` is deprecated and `Picker` is a drop-in. The Biome `/app` config
|
|
159
|
+
enforces the same two natively, so a repo that lints with Biome alone is covered without a
|
|
160
|
+
second linter.
|
|
161
|
+
|
|
162
|
+
Everything below is a widening of that one call.
|
|
163
|
+
|
|
164
|
+
### 4. Widen to the rest of the component-choice rules
|
|
165
|
+
|
|
166
|
+
`componentChoice: "all"`, or the factory directly if you are composing by hand. **Opt-in
|
|
167
|
+
and pointed at your app's source**, never at the library's:
|
|
168
|
+
|
|
169
|
+
```js
|
|
170
|
+
// eslint.config.js
|
|
171
|
+
import { createComponentChoiceRules } from "@charcuterie/eslint-config"
|
|
172
|
+
|
|
173
|
+
export default defineConfig(
|
|
174
|
+
// …the rest of your config…
|
|
175
|
+
createComponentChoiceRules({
|
|
176
|
+
files: ["packages/web/**/*.tsx"],
|
|
177
|
+
}),
|
|
178
|
+
)
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Seven rules, all errors: `charcuterie/no-raw-anchor`, `no-raw-button`, `no-raw-select`,
|
|
182
|
+
`prefer-listbox-over-select`, `no-clickable-non-interactive`,
|
|
183
|
+
`no-navigation-in-click-handler`, and `require-suppression-reason` — the last of which makes
|
|
184
|
+
every suppression of the other six carry a `-- reason`. Documentation has existed the whole
|
|
185
|
+
time and moved none of the fleet's numbers; that is the entire argument for a rule.
|
|
186
|
+
|
|
187
|
+
### 5. Turn on the flex-overflow lint rules
|
|
188
|
+
|
|
189
|
+
`flexOverflow: "warn"` on the preset, or the factory directly. Off by default, because its
|
|
190
|
+
`error` half would land the day you adopt the config — sweeping those bugs is its own
|
|
191
|
+
change:
|
|
192
|
+
|
|
193
|
+
```js
|
|
194
|
+
// eslint.config.js
|
|
195
|
+
import { createFlexOverflowRules } from "@charcuterie/eslint-config"
|
|
196
|
+
|
|
197
|
+
export default defineConfig(
|
|
198
|
+
// …the rest of your config…
|
|
199
|
+
createFlexOverflowRules({
|
|
200
|
+
files: ["packages/web/**/*.tsx"],
|
|
201
|
+
}),
|
|
202
|
+
)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
A flex item's automatic minimum size resolves against its content's **min-content width**,
|
|
206
|
+
so one long unbreakable token — a URL, a hostname, an item name — becomes the row's floor
|
|
207
|
+
and pushes the thing beside it out of the container. Four repos rediscovered this on the
|
|
208
|
+
same day. `charcuterie/no-unconstrained-flex-text` **warns** when a flex row's text child
|
|
209
|
+
declares nothing about how it may shrink; `charcuterie/no-shrink-0-with-flex-wrap`
|
|
210
|
+
**errors**, because `shrink-0` pins an element at max-content and its own `flex-wrap` can
|
|
211
|
+
then never engage.
|
|
212
|
+
|
|
213
|
+
Any escape satisfies the first rule — `min-w-0 wrap-anywhere` to wrap mid-token (`min-w-0`
|
|
214
|
+
alone is *not* enough, the text just spills), `truncate` plus a `title` or an `href`
|
|
215
|
+
carrying the full value, or an explicit `w-`/`max-w-`/`basis-`/`shrink-0`. Promote it with
|
|
216
|
+
`severity: "error"` once your app is swept.
|
|
217
|
+
|
|
218
|
+
### 6. Your `index.html`
|
|
219
|
+
|
|
220
|
+
If you use `@charcuterie/vite-config`, this one needs nothing from you and is worth knowing
|
|
221
|
+
anyway: **never put a literal `<head>` or `<body>` in a comment above the real tag.** Vite
|
|
222
|
+
finds its script-injection points with comment-blind regexes, so the first literal in the
|
|
223
|
+
file wins — the react-refresh preamble lands *inside* the comment, the dev server serves a
|
|
224
|
+
blank page, and production builds are unaffected so CI stays green. Two apps shipped it six
|
|
225
|
+
days apart. The shared Vite base now throws at dev-server start with the offending line.
|
|
226
|
+
|
|
227
|
+
### 7. Storybook
|
|
228
|
+
|
|
229
|
+
`@charcuterie/storybook-config` is a package, not a `.storybook/` to copy — two thin config
|
|
230
|
+
files and the app's Storybook themes exactly like this one. Recipe:
|
|
231
|
+
`docs/how-we-do-storybook.md` in the charcuterie repo.
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Accordion
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { Accordion } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
Eleven sites in the fleet. The plan called it "nearly free once `Tabs` exists" — it is, the
|
|
8
|
+
exclusive mode is `VisibilityGroup` and nothing else — but the saving is not why it ships.
|
|
9
|
+
|
|
10
|
+
## The two-owners bug, live, in the app this milestone migrates
|
|
11
|
+
|
|
12
|
+
mux-magic's `JobStepsDisclosure` is built on `<details>`, and `<details>` **owns `open`**. It
|
|
13
|
+
also wants the state in a Jotai atom so a job can be expanded from elsewhere. Reconciling
|
|
14
|
+
the two takes three separate mechanisms:
|
|
15
|
+
|
|
16
|
+
```tsx
|
|
17
|
+
const detailsRef = useRef<HTMLDetailsElement>(null)
|
|
18
|
+
const skipNextToggleRef = useRef(isOpen)
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (detailsRef.current) detailsRef.current.open = isOpen
|
|
22
|
+
}, [isOpen])
|
|
23
|
+
|
|
24
|
+
const handleToggle = (event) => {
|
|
25
|
+
if (skipNextToggleRef.current) {
|
|
26
|
+
skipNextToggleRef.current = false
|
|
27
|
+
return // ← swallow the toggle our own write just fired
|
|
28
|
+
}
|
|
29
|
+
setStepsOpen(…)
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A ref to reach past React, an effect to push state into the DOM, and a guard to stop the
|
|
34
|
+
DOM's echo coming back. Every one of the three exists only because **two things hold one
|
|
35
|
+
fact** — the Radix argument from `Popover`, aimed at the platform this time.
|
|
36
|
+
|
|
37
|
+
So this is a `<button aria-expanded>` and a `role="region"`, with `VisibilityGroup` holding
|
|
38
|
+
the state alone.
|
|
39
|
+
|
|
40
|
+
## Why not `<details name="…">`
|
|
41
|
+
|
|
42
|
+
The platform *does* now ship an exclusive accordion, and it was still rejected:
|
|
43
|
+
|
|
44
|
+
| | `<details name>` | This |
|
|
45
|
+
| --- | --- | --- |
|
|
46
|
+
| Who owns `open` | the DOM | `VisibilityGroup` |
|
|
47
|
+
| Disabled section | **impossible** — a `<summary>` cannot be disabled | not registered, so not a member |
|
|
48
|
+
| Driven from elsewhere | ref + effect + echo guard | pass `expandedKeys` |
|
|
49
|
+
| Panel keeps scroll/subscriptions | yes | yes (`hidden`, not unmounted) |
|
|
50
|
+
|
|
51
|
+
The second row is the one that settles it: four of the eleven sites have a section that is
|
|
52
|
+
unreachable until a job produces it.
|
|
53
|
+
|
|
54
|
+
## Two kinds, one component
|
|
55
|
+
|
|
56
|
+
`isMultiple` picks between `VisibilityGroup` and `MultiplePicker`. Hooks cannot be
|
|
57
|
+
conditional, so **both are created and one is consulted** — two empty stores and no DOM.
|
|
58
|
+
|
|
59
|
+
The alternative is reimplementing exclusivity on top of `MultiplePicker` by deselecting the
|
|
60
|
+
others, which is precisely the logic `VisibilityGroup` exists to own once.
|
|
61
|
+
|
|
62
|
+
## Registration is membership
|
|
63
|
+
|
|
64
|
+
A disabled section never registers, so nothing can expand it — including a consumer passing
|
|
65
|
+
its key in `expandedKeys`. `AllStates` does exactly that, on purpose.
|
|
66
|
+
|
|
67
|
+
## The heading level is the caller's
|
|
68
|
+
|
|
69
|
+
An accordion inside a `Card` that already has an `<h2>` needs `headingLevel={3}`. Getting it
|
|
70
|
+
wrong is a document-outline break that **no gate in this repo can see** — it depends
|
|
71
|
+
entirely on the page the accordion lands on, so it is a prop rather than a constant.
|
|
72
|
+
|
|
73
|
+
```tsx
|
|
74
|
+
<Accordion items={[
|
|
75
|
+
{ key: "details", label: "Project details", content: <p>Updated today.</p> },
|
|
76
|
+
]} />
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Published TypeScript API
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const Accordion: ({ className, expandedKeys, headingLevel, isMultiple, items, onChange, }: AccordionProps) => ReactNode
|
|
83
|
+
|
|
84
|
+
type AccordionProps = {
|
|
85
|
+
className?: string;
|
|
86
|
+
/** **Initial** only. Charcuterie owns it from then on. */
|
|
87
|
+
expandedKeys?: string[];
|
|
88
|
+
/**
|
|
89
|
+
* The heading level the triggers sit at. An accordion inside a
|
|
90
|
+
* `Card` that already has an `<h2>` needs `3`, and getting this
|
|
91
|
+
* wrong is a document-outline break that no gate here can see —
|
|
92
|
+
* it depends entirely on the page.
|
|
93
|
+
*/
|
|
94
|
+
headingLevel?: AccordionHeadingLevel;
|
|
95
|
+
/**
|
|
96
|
+
* Several sections open at once. The default is **exclusive**,
|
|
97
|
+
* because that is what every one of the fleet's disclosure groups
|
|
98
|
+
* does today.
|
|
99
|
+
*/
|
|
100
|
+
isMultiple?: boolean;
|
|
101
|
+
items: AccordionItem[];
|
|
102
|
+
onChange?: (expandedKeys: string[]) => void;
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
[Full declarations](../../dist/Accordion/Accordion.d.ts)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ActionMenu
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ActionMenu } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
The overflow control: a thing's secondary actions behind one labelled vertical-dots button.
|
|
8
|
+
|
|
9
|
+
Docket's `TaskActionMenu` and Whereabouts' `PlaceActionsMenu` were the same component — a
|
|
10
|
+
ghost neutral `IconButton`, a `useState` for visibility, a `Menu` at `placement="bottom-end"`.
|
|
11
|
+
This owns that whole shape. The caller passes the actions and a name.
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
## Name the thing, not the gesture
|
|
16
|
+
|
|
17
|
+
`label` becomes the button's accessible name, and the menu takes its name from the button.
|
|
18
|
+
Write `Actions for Cables`, never `More`: a page with twenty of these needs twenty
|
|
19
|
+
different buttons, for a screen reader and for `getByRole("button", { name })`.
|
|
20
|
+
|
|
21
|
+
## The dots
|
|
22
|
+
|
|
23
|
+
The default is three round boxes drawn in CSS. It is not a `⋮` character — a font that
|
|
24
|
+
lacks one paints nothing — and not an SVG, because the library ships no icons. Pass `icon`
|
|
25
|
+
to use the app's own glyph; Docket and Whereabouts use lucide's `EllipsisVertical` at
|
|
26
|
+
`strokeWidth={1.75}`.
|
|
27
|
+
|
|
28
|
+
## Open state
|
|
29
|
+
|
|
30
|
+
It owns its own. Clicking the trigger toggles it. Choosing an item, Escape and an outside
|
|
31
|
+
press close it. Nothing outside the button has a reason to open it.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
function ProjectActions({ archive }: { archive: () => void }) {
|
|
35
|
+
return <ActionMenu label="Project actions"
|
|
36
|
+
items={[{ key: "archive", label: "Archive", onSelect: archive }]} />
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Published TypeScript API
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
const ActionMenu: ({ icon, items, label, size, }: ActionMenuProps) => ReactNode
|
|
44
|
+
|
|
45
|
+
type ActionMenuProps = {
|
|
46
|
+
/**
|
|
47
|
+
* Replaces the default dots. Pass the app's own glyph to match an
|
|
48
|
+
* icon set exactly — Docket and Whereabouts both use lucide's
|
|
49
|
+
* `EllipsisVertical` at `strokeWidth={1.75}`.
|
|
50
|
+
*/
|
|
51
|
+
icon?: ReactNode;
|
|
52
|
+
items: MenuEntry[];
|
|
53
|
+
/**
|
|
54
|
+
* The trigger's accessible name, and through it the menu's. Name
|
|
55
|
+
* the THING, not the gesture: `Actions for Cables`, so a page with
|
|
56
|
+
* twenty of these has twenty different buttons.
|
|
57
|
+
*/
|
|
58
|
+
label: string;
|
|
59
|
+
size?: ControlSize;
|
|
60
|
+
};
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
[Full declarations](../../dist/ActionMenu/ActionMenu.d.ts)
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
# ActionTiles
|
|
2
|
+
|
|
3
|
+
```ts
|
|
4
|
+
import { ActionTiles } from "@charcuterie/ui"
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
A set of **actions** drawn as tiles — a bordered card carrying a colour bar, an icon beside
|
|
8
|
+
its name, and a line of help, in a grid that gains columns with its container.
|
|
9
|
+
|
|
10
|
+
This is [`RadioGroup`](RadioGroup.md)'s `itemShape="tile"` with
|
|
11
|
+
the radio taken away. The 2026-08-25 record that made the choice tile a `RadioGroup` shape
|
|
12
|
+
named this case under *"What this deliberately does not cover"*: mux-magic's "Pick a tool"
|
|
13
|
+
tiles are `<a href>` and points-market's are `<Link>`, and *"a link is not a radio, and
|
|
14
|
+
giving one `aria-checked` would be worse than the paint it replaced"*.
|
|
15
|
+
|
|
16
|
+
## The colour is the point, and it is not decoration
|
|
17
|
+
|
|
18
|
+
The first version of this component was neutral, and the owner's verdict on it was *"very
|
|
19
|
+
boring, not colorful"*. Three apps had already answered the question themselves — mux-magic,
|
|
20
|
+
Gallery Downloader and points-market all coloured their tiles by hand — so the paint is now
|
|
21
|
+
the library's and every one of them can stop.
|
|
22
|
+
|
|
23
|
+
A tile wears a **bar down its leading edge**, its icon takes the same hue, and the box hovers
|
|
24
|
+
in it. The hue comes from the ten-wide
|
|
25
|
+
categorical palette, which is why a set of five needs no
|
|
26
|
+
colour props at all.
|
|
27
|
+
|
|
28
|
+
It is walked in **`CATEGORICAL_SEQUENCE`**, not `1..10`. The ring itself is hue-ordered
|
|
29
|
+
because a swatch picker wants a spectrum to scan, and that is exactly what makes walking it in
|
|
30
|
+
order the worst assignment for a set: ring neighbours are 34–41° apart, the tightest pair the
|
|
31
|
+
palette has, so a two-tile set got red and orange every time. The sequence visits the same ten
|
|
32
|
+
and holds every neighbour 105° or more away.
|
|
33
|
+
|
|
34
|
+
It starts on **Teal, then Purple**, and that start is a decision rather than a by-product of
|
|
35
|
+
the spacing. Spacing alone put Red first, which made Red and Lime the pair every two-tile set
|
|
36
|
+
in the fleet drew — the owner rejected red beside green on sight. Red keeps its place in the
|
|
37
|
+
palette; it just sits between Indigo and Blue now and never neighbours Lime or Green at any
|
|
38
|
+
position, the wrap included.
|
|
39
|
+
|
|
40
|
+
The bar is `Card`'s accent-edge pseudo-element rather than a second copy of one, so a tile and
|
|
41
|
+
a [`Card`](Card.md) on the same page draw the same bar. That also
|
|
42
|
+
buys the corner: a border is painted on the border box and cannot follow a curve, which is why
|
|
43
|
+
all three hand-rolled versions in the fleet ran past the radius and stopped square.
|
|
44
|
+
|
|
45
|
+
Because it is an **overlay**, it occupies nothing in the box model — so the tile widens its
|
|
46
|
+
leading padding to make room. Without that the bar draws straight through the first letter of
|
|
47
|
+
the name, and nothing reports it: a pseudo-element is not in the DOM, so no query can miss it
|
|
48
|
+
and axe has nothing to say about a glyph with a stripe on it.
|
|
49
|
+
|
|
50
|
+
`categorical` and not `intent`, for the reason `cardAccentEdge.ts` gives: an intent is a
|
|
51
|
+
*claim* — `danger` says what happens if you press the thing — and "Builder" beside "Jobs" is
|
|
52
|
+
making no claim about either. Ten numbered hues say only "these are different from each
|
|
53
|
+
other", which is what a tile set means.
|
|
54
|
+
|
|
55
|
+
### Naming a hue, and turning them off
|
|
56
|
+
|
|
57
|
+
An item's `categorical` overrides the one its position would have given it, and the rest go on
|
|
58
|
+
walking the palette from their own positions — so naming one does not force naming all of
|
|
59
|
+
them. Worth doing when the colour belongs to the **thing** rather than to the list.
|
|
60
|
+
|
|
61
|
+
`accent="none"` is the paint this component shipped with, kept as an opt-out. Reach for it
|
|
62
|
+
when the tiles sit inside something already carrying a colour of its own, where a second
|
|
63
|
+
palette is noise rather than information.
|
|
64
|
+
|
|
65
|
+
## Which of the two you want
|
|
66
|
+
|
|
67
|
+
Ask what a press does.
|
|
68
|
+
|
|
69
|
+
- It **records a value** the user will then submit, or that filters what is below it —
|
|
70
|
+
`RadioGroup itemShape="tile"`. The set announces "3 of 6", the arrow keys move the choice,
|
|
71
|
+
and one tile stays selected.
|
|
72
|
+
- It **goes somewhere or starts something** — this. Nothing stays selected, because nothing
|
|
73
|
+
was chosen: the page moved on.
|
|
74
|
+
|
|
75
|
+
A first step that opens the next step is the second kind. QueuePilot's "Queue type" chooser
|
|
76
|
+
— *Picks* or *Rules*, and the editor for the one you press opens immediately — is the case
|
|
77
|
+
this component was built for; that same app's Tonight activity filter stays a `RadioGroup`,
|
|
78
|
+
because it holds a value the Go button below it reads.
|
|
79
|
+
|
|
80
|
+
## Why this is not a `Button` with a `className`
|
|
81
|
+
|
|
82
|
+
A `Button` is sized by `h-(--control-height-md)` and carries **no block padding at all**. It
|
|
83
|
+
is a one-line control by contract, which is what keeps every control on a form row the same
|
|
84
|
+
height at every density.
|
|
85
|
+
|
|
86
|
+
So an app that wants a wrapping two-line card reaches for `height: auto` — and that deletes
|
|
87
|
+
the height and leaves `padding: 0` down the block axis. The title sits flush against the top
|
|
88
|
+
border and the description flush against the bottom one. Nothing reports it: the class really
|
|
89
|
+
is in the DOM, TypeScript never reads the CSS, and unstyled-but-present markup passes axe.
|
|
90
|
+
|
|
91
|
+
That shipped in QueuePilot's queue-type chooser and is what this component exists to have
|
|
92
|
+
made impossible. `ActionTiles.test.tsx` reads the padding off `getComputedStyle` in a real
|
|
93
|
+
browser for the same reason.
|
|
94
|
+
|
|
95
|
+
## The box is shared, and asserted rather than trusted
|
|
96
|
+
|
|
97
|
+
`tileStyles.ts` holds the padding, the border, the radius, the surface, the type ramp, the
|
|
98
|
+
hint ramp, the gap and the grid; `RadioGroup` and `ActionTiles` both read it. Two tile sets
|
|
99
|
+
on one page have to be the same card, and "identical" spelled as two copies of one string is
|
|
100
|
+
a promise that survives exactly one edit — the same argument `CONTROL_BASE_CLASS` settles
|
|
101
|
+
between `Button` and `ButtonLink`.
|
|
102
|
+
|
|
103
|
+
The test compares **computed** styles of an action tile and a resting radio tile, not class
|
|
104
|
+
names. A class-name assertion passes while the paint is wrong.
|
|
105
|
+
|
|
106
|
+
There is exactly one difference, and it is asserted rather than waived: a coloured action tile
|
|
107
|
+
has more **leading** padding than a radio tile, by the room its bar takes. Every other side
|
|
108
|
+
matches, and `accent="none"` matches on all four — so "the boxes match" cannot quietly come to
|
|
109
|
+
mean "the boxes match apart from whatever changed last". A radio tile draws no bar at all: a
|
|
110
|
+
checked one says so by turning its whole border `intent-accent-solid`, and a coloured stripe
|
|
111
|
+
on the same box would be one card carrying two claims — *this one is selected* and *this one
|
|
112
|
+
is the blue one* — in the same place.
|
|
113
|
+
|
|
114
|
+
## `href` makes the tile a real anchor
|
|
115
|
+
|
|
116
|
+
Middle-click, ctrl-click, "open in a new tab", "copy link address" and the status bar all
|
|
117
|
+
come from the element rather than from the paint — the standing
|
|
118
|
+
[buttons are actions, links are navigation](../building-an-app.md#2-wire-the-router) rule. A same-origin
|
|
119
|
+
destination goes through the injected `RouterLink`; an external one or a fragment falls back
|
|
120
|
+
to a plain `<a>`, because pushing `https://…` or `#credits` onto the history stack navigates
|
|
121
|
+
the SPA to a route that does not exist.
|
|
122
|
+
|
|
123
|
+
A set may mix links and buttons. `isDisabled` on a link drops the `href` entirely rather than
|
|
124
|
+
shipping a focusable anchor that silently ignores clicks, and keeps `role="link"` plus
|
|
125
|
+
`aria-disabled` so it is *announced* as unavailable rather than vanishing from the tree.
|
|
126
|
+
|
|
127
|
+
## `role="group"`, and no roving tabindex
|
|
128
|
+
|
|
129
|
+
These are ordinary buttons and anchors, so the platform already owns the keyboard: Tab
|
|
130
|
+
reaches **each** tile, Enter and Space press a button, Enter follows a link.
|
|
131
|
+
|
|
132
|
+
A radio group borrows one tab stop and moves its choice with the arrow keys because exactly
|
|
133
|
+
one of its options is true at a time. Nothing here is true, so imposing that model would only
|
|
134
|
+
cost a keyboard user the ability to Tab to the second tile.
|
|
135
|
+
|
|
136
|
+
The group takes a required `label`, which names the set — "Queue type", "Pick a tool" — the
|
|
137
|
+
way a `radiogroup` is named. A set of unnamed tiles is a pile of buttons.
|
|
138
|
+
|
|
139
|
+
## A tile may lead with an icon, beside the name
|
|
140
|
+
|
|
141
|
+
The icon sits **to the left of the title**, with the hint below both — which is how all three
|
|
142
|
+
apps that had grown this card by hand drew it, and how the owner asked for it back: *"I like
|
|
143
|
+
how Mux-Magic looks today with the icon to the left of the title."*
|
|
144
|
+
|
|
145
|
+
It takes the tile's hue, so an app passes a `stroke="currentColor"` path and states no colour
|
|
146
|
+
of its own. Size is the app's; around 22px at `md` and 30px at `lg` reads the way those
|
|
147
|
+
hand-rolled cards did. The library still ships no icons.
|
|
148
|
+
|
|
149
|
+
`icon` is `aria-hidden` by construction, because the name it sits beside is inside the same
|
|
150
|
+
tile — an announced icon is the label read twice.
|
|
151
|
+
|
|
152
|
+
## The grid takes its columns from the container
|
|
153
|
+
|
|
154
|
+
`repeat(auto-fill, minmax(min(var(--charcuterie-tile-min-inline-size), 100%), 1fr))` — the
|
|
155
|
+
same constant `RadioGroup`'s tile shape uses, and each of its three parts is load-bearing:
|
|
156
|
+
|
|
157
|
+
- **`auto-fill`, not `auto-fit`.** `auto-fit` collapses the empty tracks and lets the
|
|
158
|
+
survivors share the whole row, so six tiles in a 2560px container become six 420px slabs —
|
|
159
|
+
the full-width-row shape in a new costume.
|
|
160
|
+
- **`min(…, 100%)`.** Without it the 200px floor overflows a container narrower than one
|
|
161
|
+
tile, which is a horizontal scrollbar in the Narrow View.
|
|
162
|
+
- **A custom property, not an interpolated class.** Tailwind scans source *text* for complete
|
|
163
|
+
class strings, so `` `grid-cols-[…${n}px…]` `` generates nothing, paints nothing and
|
|
164
|
+
reports nothing.
|
|
165
|
+
|
|
166
|
+
### The floor sizes the CONTAINER's tracks, not the tiles
|
|
167
|
+
|
|
168
|
+
`minTileInlineSize` is the narrowest a **track** may be, and `auto-fill` lays as many of
|
|
169
|
+
them as fit whether or not there are tiles to put in them. So the number to pick comes from
|
|
170
|
+
the width of the box the set is in, divided by how many tiles you want across it — not from
|
|
171
|
+
how many tiles you have.
|
|
172
|
+
|
|
173
|
+
Leave it at the 200px default in a 1024px container and the grid cuts four tracks. Two
|
|
174
|
+
tiles take the first two, the other half of the row is empty background, and the set reads
|
|
175
|
+
as a layout bug.
|
|
176
|
+
|
|
177
|
+
⚠️ **Nothing reports this.** It type-checks, it lints, it passes every unit and e2e test,
|
|
178
|
+
and the DOM is correct — the tiles really are in a grid, and the grid really has the columns
|
|
179
|
+
it was asked for. Three apps shipped a half-empty row on the day they adopted this
|
|
180
|
+
component, and each one was caught by a screenshot. If a set has few tiles, look at it.
|
|
181
|
+
|
|
182
|
+
This is **not** `useAdaptiveColumns`. That hook buys a column with **height**, for an
|
|
183
|
+
unbounded gallery that is going to scroll; a tile set is a bounded group inside a form section
|
|
184
|
+
or a first step, where the only question is how many fit across the box it was given.
|
|
185
|
+
|
|
186
|
+
## What this deliberately does not do
|
|
187
|
+
|
|
188
|
+
- **Hold a selection.** That is `RadioGroup itemShape="tile"`, and giving these tiles
|
|
189
|
+
`aria-checked` would be the mistake the 2026-08-25 record refused.
|
|
190
|
+
- **Toggle per tile.** A multi-select tile is a checkbox group and a different record.
|
|
191
|
+
- **Carry artwork.** That is [`MediaTile`](MediaTile.md).
|
|
192
|
+
|
|
193
|
+
```tsx
|
|
194
|
+
function StartProject({ createProject }: { createProject: () => void }) {
|
|
195
|
+
return <ActionTiles label="Start a project" onChoose={createProject}
|
|
196
|
+
items={[
|
|
197
|
+
{ label: "Create", value: "create", hint: "Start with a blank project" },
|
|
198
|
+
{ href: "/templates", label: "Browse templates", value: "templates" },
|
|
199
|
+
]} />
|
|
200
|
+
}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Published TypeScript API
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
const ActionTiles: ({ accent, className, items, label, minTileInlineSize, newTabLabel, onChoose, size, }: ActionTilesProps) => ReactNode
|
|
207
|
+
|
|
208
|
+
type ActionTilesProps = {
|
|
209
|
+
/**
|
|
210
|
+
* Whether the set colours itself. `auto` by default — see
|
|
211
|
+
* {@link ActionTilesAccent}.
|
|
212
|
+
*/
|
|
213
|
+
accent?: ActionTilesAccent;
|
|
214
|
+
className?: string;
|
|
215
|
+
items: readonly ActionTileItem[];
|
|
216
|
+
/** The set's accessible name. Required. */
|
|
217
|
+
label: string;
|
|
218
|
+
/**
|
|
219
|
+
* The narrowest a tile track may be, in CSS px.
|
|
220
|
+
*
|
|
221
|
+
* It is the grid's floor and not the tile's width: tracks below it
|
|
222
|
+
* are not created, and the ones that are share the row evenly.
|
|
223
|
+
*/
|
|
224
|
+
minTileInlineSize?: number;
|
|
225
|
+
/** Fired by a tile that carries no `href`. */
|
|
226
|
+
onChoose?: (value: string) => void;
|
|
227
|
+
/** What `isExternal` announces. Not shown. */
|
|
228
|
+
newTabLabel?: string;
|
|
229
|
+
size?: ControlSize;
|
|
230
|
+
};
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
[Full declarations](../../dist/ActionTiles/ActionTiles.d.ts)
|