@supersuit/components 0.0.0-stage → 0.3.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/LICENSE +21 -0
  3. package/README.md +338 -2
  4. package/bin/supersuit-theme.mjs +116 -0
  5. package/dist/app-shell/app-shell.d.ts +68 -0
  6. package/dist/app-shell/app-shell.js +62 -0
  7. package/dist/app-shell/index.d.ts +3 -0
  8. package/dist/app-shell/index.js +5 -0
  9. package/dist/app-shell/sheet.d.ts +14 -0
  10. package/dist/app-shell/sheet.js +57 -0
  11. package/dist/app-shell/styles.css +112 -0
  12. package/dist/check/depth/bar.d.ts +27 -0
  13. package/dist/check/depth/bar.js +40 -0
  14. package/dist/check/depth/check.d.ts +40 -0
  15. package/dist/check/depth/check.js +50 -0
  16. package/dist/check/depth/crop.d.ts +24 -0
  17. package/dist/check/depth/crop.js +126 -0
  18. package/dist/check/depth/index.d.ts +3 -0
  19. package/dist/check/depth/index.js +5 -0
  20. package/dist/check/depth/measure.d.ts +42 -0
  21. package/dist/check/depth/measure.js +141 -0
  22. package/dist/check/depth/parts-page.d.ts +6 -0
  23. package/dist/check/depth/parts-page.js +69 -0
  24. package/dist/check/depth/playwright.d.ts +4 -0
  25. package/dist/check/depth/playwright.js +10 -0
  26. package/dist/check/depth/png.d.ts +3 -0
  27. package/dist/check/depth/png.js +12 -0
  28. package/dist/check/depth/shoot.d.ts +37 -0
  29. package/dist/check/depth/shoot.js +30 -0
  30. package/dist/choice-chips/choice-chips.d.ts +40 -0
  31. package/dist/choice-chips/choice-chips.js +106 -0
  32. package/dist/choice-chips/index.d.ts +1 -0
  33. package/dist/choice-chips/index.js +3 -0
  34. package/dist/choice-chips/styles.css +38 -0
  35. package/dist/index.d.ts +4 -0
  36. package/dist/index.js +11 -0
  37. package/dist/page-header/index.d.ts +2 -0
  38. package/dist/page-header/index.js +4 -0
  39. package/dist/page-header/page-header.d.ts +58 -0
  40. package/dist/page-header/page-header.js +124 -0
  41. package/dist/page-header/shell-context.d.ts +12 -0
  42. package/dist/page-header/shell-context.js +21 -0
  43. package/dist/page-header/styles.css +77 -0
  44. package/dist/row/index.d.ts +1 -0
  45. package/dist/row/index.js +3 -0
  46. package/dist/row/row.d.ts +76 -0
  47. package/dist/row/row.js +69 -0
  48. package/dist/row/styles.css +69 -0
  49. package/dist/sound/engine.d.ts +59 -0
  50. package/dist/sound/engine.js +325 -0
  51. package/dist/sound/index.d.ts +18 -0
  52. package/dist/sound/index.js +10 -0
  53. package/dist/sound/synth.d.ts +24 -0
  54. package/dist/sound/synth.js +139 -0
  55. package/dist/theme/color.d.ts +29 -0
  56. package/dist/theme/color.js +116 -0
  57. package/dist/theme/compile.d.ts +23 -0
  58. package/dist/theme/compile.js +138 -0
  59. package/dist/theme/index.d.ts +3 -0
  60. package/dist/theme/index.js +4 -0
  61. package/dist/theme/record.d.ts +90 -0
  62. package/dist/theme/record.js +222 -0
  63. package/dist/voice-field/box-trace.d.ts +18 -0
  64. package/dist/voice-field/box-trace.js +87 -0
  65. package/dist/voice-field/index.d.ts +8 -0
  66. package/dist/voice-field/index.js +10 -0
  67. package/dist/voice-field/recorder.d.ts +71 -0
  68. package/dist/voice-field/recorder.js +211 -0
  69. package/dist/voice-field/rules.d.ts +27 -0
  70. package/dist/voice-field/rules.js +62 -0
  71. package/dist/voice-field/saved-take.d.ts +7 -0
  72. package/dist/voice-field/saved-take.js +66 -0
  73. package/dist/voice-field/store.d.ts +27 -0
  74. package/dist/voice-field/store.js +40 -0
  75. package/dist/voice-field/styles.css +161 -0
  76. package/dist/voice-field/toast.d.ts +13 -0
  77. package/dist/voice-field/toast.js +26 -0
  78. package/dist/voice-field/voice-field.d.ts +80 -0
  79. package/dist/voice-field/voice-field.js +259 -0
  80. package/dist/voice-field/words.d.ts +37 -0
  81. package/dist/voice-field/words.js +33 -0
  82. package/package.json +126 -4
  83. package/specs/brand-theme/v1/SPEC.md +130 -0
  84. package/specs/brand-theme/v1/default-bar.json +1196 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,55 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 (2026-12-02)
4
+
5
+ The first four components of the component library adoption and desktop superarchitecture, built from the specs approved 2026-12-02 with every open-question recommendation taken.
6
+
7
+ - **row** (`@supersuit/components/row`): `Row`, `RowList` and `Fold`. One target per row (a link, else a button), an optional `action` beside it, pressed (dropped by a drag past 10 px), selected (`aria-current="page"`), unread, two title lines on a phone and one from 1024 px, and a fold with `aria-expanded` and `aria-controls`.
8
+ - **choice-chips** (`@supersuit/components/choice-chips`): `ChoiceChips` in two modes. Pick several: `aria-pressed` toggle chips with a tick. Pick one: a segmented `radiogroup` with roving focus and arrow keys that skip disabled options, a second tap that clears only an optional question, and a measured switch to wrapping chips when the track does not fit. Every chip at least 44 px tall.
9
+ - **page-header** (`@supersuit/components/page-header`): `PageHeader`. The phone back row with the title under it, a floating Back driven by `@supersuit/home-screen-app`'s `backReveal` (passed in), a More menu with Suggest a change and My suggestions at the bottom, and inside the app shell from 1024 px a 72 px title row with no Back, a detail-pane `h2`, a round icon action in the narrow list pane so its title keeps its room, and a "‹ Parent" crumb on a deeper screen. Also `ShellContext`, `useDesktop` and `DESKTOP_QUERY`.
10
+ - **app-shell** (`@supersuit/components/app-shell`): `AppShell`, `ShellSheet` and `HomeColumns`. A 30rem phone column below 1024 px; from 1024 px a 240 px side menu drawn from the tile list (filled and outlined counts, off tiles left out, the More folder only while it waits) and a single 52rem page or a 360 px list beside its open item. A sheet becomes a centred 560 px dialog that traps focus. The skip link comes first; opening an item moves focus to its heading.
11
+
12
+ ## 0.2.0 (2026-12-01)
13
+
14
+ Brand themes, one sound engine, a measured depth check and the `@supersuit` registry. Approved in the component library on shadcn superarchitecture (2026-12-01). The first version on npm; 0.1.0 was never published.
15
+
16
+ ### theme (`@supersuit/components/theme`) and `supersuit-theme`
17
+
18
+ - The `brand-theme/v1` format, with its spec in `specs/brand-theme/v1/SPEC.md`. The spec ships in the package and has no public URL yet.
19
+ - `validateTheme(record)` names each field that is wrong. `compileTheme(record, options)` writes the CSS variables, the eleven depth utilities, a shadcn `registry:theme` item and the sound recipe. `--flat` is round 1, with every depth setting at zero.
20
+ - `supersuit-theme build <record> [--out] [--flat] [--only depth] [--scope] [--map] [--check] [--json]`. Exit 0 done, 1 refused or not current, 2 usage.
21
+ - Maison Dawn, Maison Night and the invented Garden theme.
22
+
23
+ ### sound (`@supersuit/components/sound`)
24
+
25
+ - One engine for every app: sounds made in code, no audio files. Five moment sounds on by default, four press sounds off until "All interface sounds", and a separate haptics switch.
26
+
27
+ ### check/depth (`@supersuit/components/check/depth`)
28
+
29
+ - `partsPage`, `measureParts` and `checkDepth`: the depth check from the pixels of a screenshot at phone size. It needs no PNG decoder and no browser.
30
+ - `@supersuit/components/check/depth/playwright`: `shootParts`, `depthCompare` (the crop picture), `decodePng`, `encodePng` and the bar math. It needs `pngjs`, now an optional peer dependency.
31
+ - The default bar is measured: round 1 fails and round 3 passes on all three themes, in Chromium and WebKit.
32
+
33
+ ### The registry (`npm run registry`)
34
+
35
+ - `registry.json` and `public/r/{style,depth,theme-maison-dawn,theme-maison-night,theme-garden,sounds}.json` in shadcn's registry-item shape, built locally. `https://components.supersuit.co` serves them only after its first deploy.
36
+ - `style`: the 22 owned parts on Base UI. shadcn's site-only `IconPlaceholder` is replaced by the lucide-react icon it names, so the parts compile in any app.
37
+
38
+ ### Build
39
+
40
+ - `scripts/check-dist.mjs` refuses a missing subpath, and a subpath that reaches a package that is not a dependency or a peer.
41
+ - `npm run check:consumer` also imports `theme`, `sound` and `check/depth` from the packed tarball, and runs `supersuit-theme --help`.
42
+
43
+ ## 0.1.0 (2026-11-30)
44
+
45
+ First release of the Supersuit component library. One folder per component: its approved spec and mockup in `specs/<name>/`, the React implementation in `src/<name>/`, a conformance test in `test/<name>/`. Each component is its own subpath export, so an app imports only the one it uses. The root names the components and imports none.
46
+
47
+ ### voice-field (`@supersuit/components/voice-field`)
48
+
49
+ Extracted from the golden VoiceField and Recorder in Supertools (helm-template, `helm2/src/golden/voice-field` and `helm2/src/golden/recorder`). Built first as `@supersuit/voice-field`, never published under that name, and folded into this library the same day (Gary, 2026-11-30: "why not create a single components package").
50
+
51
+ - `VoiceField`: one box with the words, the mic and Send inside it. The time, the wait and kept recordings are drawn inside the box, as approved on 2026-11-30 (`specs/voice-field/`).
52
+ - `Recorder`: the mic on its own. Tap to start and stop, or hold and let go, decided by how long the take has run. `aria-pressed` while recording.
53
+ - Cut loose from Supertools: the app passes `transcribe`, a `store`, a `toast` function and any `words`. With no `transcribe`, every take is kept on the device with play and remove.
54
+ - Two themes from the Maison tokens, `vf-theme-dawn` and `vf-theme-night`, styled through `--vf-*` variables, in `@supersuit/components/voice-field/styles.css`.
55
+ - `BoxTrace`, `SavedTake`, `VoiceToasts`, `memoryStore` and the pure rules (`releaseIsTap`, `silenceWatch`, `micError`, `clock`).
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 SupersuitUp
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,339 @@
1
- # Temporary Holding Version
1
+ # @supersuit/components
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Supersuit component library. Each component is one folder with its approved spec, its mockup, a React implementation and a conformance test.
4
+
5
+ ## How the library works
6
+
7
+ - **One folder per component.** `specs/<name>/` holds the spec (`SPEC.md`: its states, sizes, behaviour, words and Maison tokens) and the approved mockup. `src/<name>/` holds the React implementation. `test/<name>/conformance.test.tsx` renders every state the spec names.
8
+ - **The spec is the component.** Any stack can build it: follow `SPEC.md` and the mockup. This repo holds the React implementation.
9
+ - **Import only what you use.** Each component is its own subpath, so an app that imports one component gets only that one. The root entry imports no component; it exports `components`, the list this version ships.
10
+
11
+ ```tsx
12
+ import { VoiceField } from '@supersuit/components/voice-field'
13
+ import '@supersuit/components/voice-field/styles.css'
14
+ ```
15
+
16
+ | Component | Import | Spec |
17
+ | --- | --- | --- |
18
+ | Voice field: one text box that can also be spoken | `@supersuit/components/voice-field` | [specs/voice-field](specs/voice-field/SPEC.md) |
19
+ | Row: one line in a list, and the fold that groups rows | `@supersuit/components/row` | [specs/row](specs/row/SPEC.md) |
20
+ | Choice chips: pick one or pick several, as pills | `@supersuit/components/choice-chips` | [specs/choice-chips](specs/choice-chips/SPEC.md) |
21
+ | Page header: Back, the screen's name and More | `@supersuit/components/page-header` | [specs/page-header](specs/page-header/SPEC.md) |
22
+ | App shell: a phone column, or a side menu and a wide main area from 1024 px | `@supersuit/components/app-shell` | [specs/app-shell](specs/app-shell/SPEC.md) |
23
+
24
+ `test/library.test.ts` refuses a component that is missing its spec, its mockup, its conformance test, its subpath export or its place in the `components` list.
25
+
26
+ ## Voice field
27
+
28
+ One text box that can also be spoken. A React text field with a microphone inside it. It keeps every recording on the device until the recording is safely turned into words. It was extracted from the VoiceField and Recorder in Supertools, where it runs on every text box.
29
+
30
+ **The spec is [specs/voice-field/SPEC.md](specs/voice-field/SPEC.md)**, with [the approved mockup](specs/voice-field/approved-2026-11-30.png) ([its HTML source](specs/voice-field/approved-2026-11-30.html)). The mockup shows the five states in the light Dawn theme and the dark Maison night theme.
31
+
32
+ ### 30 seconds
33
+
34
+ ```bash
35
+ npm install @supersuit/components
36
+ ```
37
+
38
+ ```tsx
39
+ import '@supersuit/components/voice-field/styles.css'
40
+ import { useState } from 'react'
41
+ import { VoiceField, VoiceToasts, memoryStore } from '@supersuit/components/voice-field'
42
+
43
+ const store = memoryStore() // use an IndexedDB store in a real app (see "The store")
44
+
45
+ export function Note() {
46
+ const [text, setText] = useState('')
47
+ return (
48
+ <div className="vf-theme-dawn">
49
+ <VoiceField store={store} id="note" label="Why it matters" placeholder="Why it matters (optional)" multiline
50
+ value={text} onChange={setText}
51
+ transcribe={async (key, blob, ms) => {
52
+ const r = await fetch('/api/transcribe', { method: 'POST', body: blob })
53
+ if (r.status >= 500) throw new Error('away') // thrown: the take is kept and sent again later
54
+ if (!r.ok) return { refused: `status ${r.status}` } // refused: the take is kept, and the person is told
55
+ return { text: (await r.json()).text }
56
+ }}
57
+ onSend={() => { /* send text */ }} />
58
+ <VoiceToasts />
59
+ </div>
60
+ )
61
+ }
62
+ ```
63
+
64
+ ### The five states
65
+
66
+ 1. **Empty.** A quiet mic waits inside the box.
67
+ 2. **Recording.** The mic turns red with a stop square. Its ring grows with your voice. The time shows in the box.
68
+ 3. **Turning speech into words.** The box is read-only, says "Writing down what you said", and shows a thin progress line. Send waits.
69
+ 4. **Words filled in.** The heard words are added after what was typed. Send sits inside the box, beside the mic.
70
+ 5. **Saved, not sent yet.** A recording that could not be sent stays in the box with play, its waveform, its length and remove, over "Will send when you're back online".
71
+
72
+ `test/voice-field/conformance.test.tsx` renders each state in both themes.
73
+
74
+ ### The rules it keeps
75
+
76
+ - **Tap to start, tap again to stop. Or hold, and let go to stop.** Tap or hold is decided by how long the take has run when the finger lifts, never by the time since the press. A phone opens its microphone slowly, so timing from the press read a tap as a short hold.
77
+ - **A cancelled touch never stops a take.** The take keeps going until the next tap.
78
+ - **The microphone is asked for inside the press**, before anything is awaited, so iPhone Safari counts the press as the gesture.
79
+ - **The mic is `aria-pressed` while it records.**
80
+ - **Nothing said is lost.** The default recorder writes every second of a take to the store as it is recorded. A take is deleted from the device only after the transcriber answered with its words. A take the transcriber refused, or could not be reached for, is kept and sent again on the next open, when the network comes back, and every 15 seconds.
81
+ - **No transcriber, no problem.** Leave out `transcribe` (a hosted page with no computer behind it) and every take is kept in the box with play and remove. Read the audio with `takeBlob(store, key)`.
82
+ - **Typed words are saved as they are typed** and put back on the next open, with "Restored your unsent note". The words a screen opens the field with are not a draft. A clear deletes the draft at once.
83
+
84
+ ### Props
85
+
86
+ | Prop | What it does |
87
+ | --- | --- |
88
+ | `store` | Required. Where drafts and recordings are kept (see "The store"). |
89
+ | `id` | Required. Names this field's draft and kept recordings. Keep it stable across visits. |
90
+ | `label` | Required. The field's name, for a screen reader. The mic is "Say it: {label}". |
91
+ | `value`, `onChange` | The words, controlled. |
92
+ | `placeholder`, `multiline`, `rows`, `type`, `autoFocus` | As on any text field. `rows` opens a multiline box that many lines tall. |
93
+ | `transcribe(key, blob, ms)` | Turns a take into words. Return `{ text }`, return `{ refused }` to keep it and say why, or throw when the transcriber cannot be reached. Absent: every take is kept. |
94
+ | `onHeard({ text, ms })` | A take became words. |
95
+ | `onKept({ key, ms })` | The screen keeps takes itself. Without it, the field keeps them and shows them in the box. |
96
+ | `onHearing(bool)` | A take started or stopped being written down. |
97
+ | `onSend`, `sendDisabled`, `sendLabel` | Draws Send inside the box. |
98
+ | `persist` | Save typed words as they are typed. Default `true`. |
99
+ | `disabled` | Disables the mic. |
100
+ | `toast` | The app's own toast function, `({ id, text, tone, ms }) => void`. Default: the package's, shown by `<VoiceToasts />`. |
101
+ | `words` | Replace any sentence. See `VoiceFieldWords` in `src/voice-field/words.ts`. Each is a function read when it is said. |
102
+ | `reach` | `{ mark(up), check(force) }`: whether the transcriber can be reached. Default reads `navigator.onLine`. |
103
+ | `isUnreachable(e)` | Whether a thrown error means the transcriber is away (then `reach.mark(false)`). Default: every error. |
104
+ | `newKey()` | Makes the key a take is stored under. |
105
+ | `startTake` | The recording layer. Default: `@supersuit/suggest-a-change`'s, which writes each second to the store. |
106
+ | `status` | Show the time, the wait and the waiting note inside the box. Default `true`. |
107
+ | `savedTakes` | Show kept recordings in the box. Default `true`. |
108
+ | `Mic` | A component in place of the package's `Recorder`, for an app that wraps it with its own defaults. |
109
+ | `micKey` | Sets `data-key-hint` on the mic, for an app that draws a keyboard hint. |
110
+ | `leading` | Drawn inside the box before the words (a search magnifier). |
111
+ | `className`, `inputClassName`, `sendClassName`, `labelClassName` | Extra classes, for an app that draws the box with its own CSS. The label is always visually hidden. |
112
+
113
+ `Recorder` is the mic on its own, with the same rules. Its extra props: `size` (`inline`, `small`, `large`), `badge` (the time on the button), `onState`, `inlineWait` (`ring` or `trace`), `keyEvent` (the event `pressVoice(el, 'toggle' | 'cancel', event)` sends) and `classNames`.
114
+
115
+ ### The store
116
+
117
+ The field never opens a database itself. It takes a store with two shelves, `kv` for small records and `blobs` for audio:
118
+
119
+ ```ts
120
+ interface VoiceStore {
121
+ get<T>(shelf: 'kv' | 'blobs', key: string): Promise<T | undefined>
122
+ put(shelf: 'kv' | 'blobs', key: string, value: unknown): Promise<void>
123
+ del(shelf: 'kv' | 'blobs', key: string): Promise<void>
124
+ }
125
+ ```
126
+
127
+ `openStore()` from `@supersuit/suggest-a-change/client` is an IndexedDB store with this shape. `memoryStore()` keeps nothing past a reload, so use it only in tests.
128
+
129
+ ### Themes
130
+
131
+ Two themes ship in `styles.css`. Put the class, or `data-vf-theme`, on the field or on any element above it.
132
+
133
+ | Theme | Where | Ground | To press | Focus |
134
+ | --- | --- | --- | --- | --- |
135
+ | `vf-theme-dawn` (default) | Member screens | Dawn `#F3E5D5`, card `#FAF7F2` | Navy `#22324A` | Slate `#2B3B50` |
136
+ | `vf-theme-night` | Artifacts pages | Night `#17171A` | Bronze `#A8834F` | Bronze |
137
+
138
+ The recording red (`#DE6152`) and the answering teal (`#58E1D1`) are the same in both.
139
+
140
+ To restyle, set the variables: `--vf-ground`, `--vf-card`, `--vf-field`, `--vf-text`, `--vf-mute`, `--vf-placeholder`, `--vf-line`, `--vf-border`, `--vf-accent`, `--vf-filled`, `--vf-on-filled`, `--vf-rec`, `--vf-rec-text`, `--vf-on`, `--vf-on-live`, `--vf-toast-bg`, `--vf-toast-text`, `--vf-radius`, `--vf-font`, and the trace colours `--vf-trace-tail`, `--vf-trace-head`, `--vf-trace-rec-tail`, `--vf-trace-rec-head`.
141
+
142
+ An app with its own CSS can skip `styles.css` and pass classes instead (`className`, `classNames`). Supertools does this.
143
+
144
+ ## Row
145
+
146
+ One line in a list: an optional picture, a title, a quieter second line, and one end item (a count, a chevron or a time). A `Fold` groups rows, says how many it holds, and opens or closes. The spec is [specs/row/SPEC.md](specs/row/SPEC.md).
147
+
148
+ ```tsx
149
+ import { Row, RowList, Fold } from '@supersuit/components/row'
150
+ import '@supersuit/components/row/styles.css'
151
+
152
+ <RowList>
153
+ <Row href="/meetings/1" title="Weekly sync" second="Ada and Bo, 45 minutes" lead={{ initials: 'AB' }} end={{ time: 'Tue' }} unread />
154
+ </RowList>
155
+ <Fold label="Done" count={2} open={open} onToggle={setOpen}>
156
+ <Row href="/x" title="Rent" end={{ chevron: true }} />
157
+ </Fold>
158
+ ```
159
+
160
+ - The whole row is one target: a link with `href` (`linkAs` takes Next.js `Link`), else a button. `action` draws an optional button beside it, never inside it.
161
+ - `selected` sets `aria-current="page"`; use it only in a desktop list beside its detail. `unread` adds the dot and "Unread" before the name. A count is read as "{n} waiting".
162
+ - A title takes two lines on a phone and one from 1024 px or in a `look="pane"` list (`titleLines` overrides). The colours are the theme roles a compiled brand theme sets (`.theme-maison-dawn`, `.theme-maison-night`); with no theme, Maison Dawn.
163
+ - `test/row/conformance.test.tsx` renders every state in both themes.
164
+
165
+ ## Choice chips
166
+
167
+ Pick one or pick several, as pills, every chip at least 44 px tall. The spec is [specs/choice-chips/SPEC.md](specs/choice-chips/SPEC.md).
168
+
169
+ ```tsx
170
+ import { ChoiceChips } from '@supersuit/components/choice-chips'
171
+ import '@supersuit/components/choice-chips/styles.css'
172
+
173
+ <ChoiceChips mode="several" label="Category" optional options={[{ value: 'meals', label: 'Meals' }]} value={tags} onChange={setTags} />
174
+ <ChoiceChips mode="one" label="Paid with" required options={[{ value: 'me', label: 'I paid' }, { value: 'company', label: 'The company paid' }]} value={paid} onChange={setPaid} />
175
+ ```
176
+
177
+ - **Pick several** is a `role="group"` of `aria-pressed` buttons. A chosen chip is filled and carries a tick. A disabled option stays focusable, is `aria-disabled`, and is described by the help line.
178
+ - **Pick one** is a `role="radiogroup"`: one option in the tab order, arrow keys move the choice and skip disabled options. A second tap clears an `optional` question, never a `required` one.
179
+ - A track that does not fit its container draws as wrapping chips with the same radio semantics. The switch is measured with a `ResizeObserver`; `layout="track"` or `"wrap"` forces one form.
180
+ - `onChange` runs on every tap. There is no Apply button.
181
+
182
+ ## Page header
183
+
184
+ The top of every screen below the home: Back, the screen's name, and the three-dots More menu with Suggest a change. The spec is [specs/page-header/SPEC.md](specs/page-header/SPEC.md).
185
+
186
+ ```tsx
187
+ import * as homeScreen from '@supersuit/home-screen-app' // backReveal and backRevealAt
188
+ import { PageHeader } from '@supersuit/components/page-header'
189
+ import '@supersuit/components/page-header/styles.css'
190
+
191
+ <PageHeader title="Lunch with Ada" back={{ href: '/expenses', label: 'Expenses' }} backReveal={homeScreen}
192
+ actions={[{ label: 'Edit', icon: <Pencil /> }]} onSuggest={openSuggest} onMySuggestions={openMine} />
193
+ ```
194
+
195
+ - **Back is a link to a fixed parent**, named "Back to {parent}", never `history.back()`.
196
+ - **On a phone** (and at every width outside the app shell): the 44 px back row, then the title under it. The floating Back is drawn only while `backReveal` says it is shown. It follows the page and any scroller at least 60% of the window tall.
197
+ - **On a desktop inside the app shell** (1024 px and up): a 72 px title row with no Back. Each action is a filled pill with its word. `pane="detail"` makes the item title an `h2`; `pane="list"` keeps the screen's `h1`. `deep` adds the "‹ Parent" crumb.
198
+ - **More** is a menu button: the app's `menu` items, then Suggest a change and My suggestions. Arrow keys move, Enter picks, Escape closes and returns focus to More. `signedIn={false}` drops it.
199
+ - The shell's state (`ShellContext`, `useDesktop`, `DESKTOP_QUERY`) is exported here too. The app shell provides it.
200
+ - `@supersuit/home-screen-app` is not a dependency of this package, so the app passes its rule in. Without `backReveal`, nothing floats.
201
+
202
+ ## App shell
203
+
204
+ The page frame every app sits in. Below 1024 px it is one phone column, at most 30rem, with safe-area padding. From 1024 px (measured on the window) it is a 240 px side menu and a wide main area. The spec is [specs/app-shell/SPEC.md](specs/app-shell/SPEC.md).
205
+
206
+ ```tsx
207
+ import { AppShell, ShellSheet } from '@supersuit/components/app-shell'
208
+ import '@supersuit/components/app-shell/styles.css'
209
+
210
+ const tiles = [
211
+ { id: 'waiting', name: 'Waiting on you', href: '/waiting', icon: <Inbox />, count: 3, waiting: true },
212
+ { id: 'meetings', name: 'Meetings', href: '/meetings', icon: <Calendar />, count: 12 },
213
+ ]
214
+
215
+ <AppShell appName="Cofounders" tiles={tiles} current="meetings" person={{ name: 'Ada Lovelace' }}
216
+ layout="list-detail" thing="meeting" listLabel="Meetings" list={<RowList look="pane">...</RowList>}
217
+ detailLabel={item?.title} detailHeader={item && <PageHeader pane="detail" title={item.title} back={{ href: '/meetings' }} />}
218
+ detail={item && <Meeting item={item} />} />
219
+ ```
220
+
221
+ - **The shell draws the side menu from `tiles`**, the same list the launcher reads: icon, name, count. A filled count waits on this person (`waiting`); an outlined one is a plain total. `off` tiles are left out. `folder: 'more'` tiles show under the separator only while something in them waits. `extra` holds app-wide entries such as Search.
222
+ - **A screen declares its layout:** `single` (one page, at most 52rem) or `list-detail` (a 360 px list and a detail pane whose text is at most 44rem). On a phone, the open item shows alone. When another item opens, focus goes to the detail pane's heading.
223
+ - **`ShellSheet`** is a sheet on a phone and a centred 560 px dialog from 1024 px, with the same content. Escape, the scrim and Close close it. It traps focus and gives it back.
224
+ - `HomeColumns` sets the home's sections side by side on a desktop. `grow` lets a screen widen to 44rem from 768 px inside the phone column.
225
+ - "Skip to content" is the first focusable item. The layout is plain CSS media queries, so it works in Next.js and Vite apps alike; the same 1024 px query, read in script, tells the page header and the sheet which form to take.
226
+
227
+ ## Brand themes: `@supersuit/components/theme` and `supersuit-theme`
228
+
229
+ A brand theme is one JSON record in the `brand-theme/v1` format: colours, type, corner, depth, sounds and the depth bar. The spec is [specs/brand-theme/v1/SPEC.md](specs/brand-theme/v1/SPEC.md). It ships in the package at the same path, and it has no public URL yet. Maison's records are `themes/maison-dawn.theme.json` and `themes/maison-night.theme.json`. `fixtures/garden/garden.theme.json` is an invented brand that proves any brand works.
230
+
231
+ ```ts
232
+ import { validateTheme, compileTheme } from '@supersuit/components/theme'
233
+
234
+ const problems = validateTheme(record) // [] when the record is good; else each field and what is wrong
235
+ const { css, registryItem, sounds } = compileTheme(record)
236
+ ```
237
+
238
+ The same from a terminal:
239
+
240
+ ```bash
241
+ npx supersuit-theme build themes/maison-dawn.theme.json --out out/ # maison-dawn.css, .registry.json, .sounds.json
242
+ npx supersuit-theme build themes/maison-dawn.theme.json --out out/ --check # exit 1 naming each output that is not current
243
+ npx supersuit-theme build themes/maison-dawn.theme.json --flat # round 1: every depth setting at zero
244
+ npx supersuit-theme build themes/maison-dawn.theme.json --only depth --scope 'html[data-depth="on"]'
245
+ npx supersuit-theme --help
246
+ ```
247
+
248
+ Exit codes: 0 done, 1 a refused record or an output that differs, 2 usage.
249
+
250
+ ## Sound: `@supersuit/components/sound`
251
+
252
+ One sound engine for every app. It makes each sound in code (no audio files), plays it, and gives the matching haptic. It has no React, so plain JavaScript can import it.
253
+
254
+ ```ts
255
+ import { sound } from '@supersuit/components/sound'
256
+
257
+ sound.install(document, { recipe: theme.sounds }) // the tap listener, the audio unlock and the tap haptic
258
+ sound.play('success')
259
+ sound.haptic('success')
260
+ ```
261
+
262
+ Five moment sounds are on by default: `success`, `error`, `send`, `record-start`, `record-stop`. Four press sounds are off until the person turns on "All interface sounds": `tap`, `toggle-on`, `toggle-off`, `sheet-open`. Three switches are kept on the device: `sounds` (all sounds), `pressSounds` ("All interface sounds") and `haptics`. Read one with `sound.setting('sounds')` and change it with `sound.setSetting('sounds', false)`.
263
+
264
+ ## Depth check: `@supersuit/components/check/depth`
265
+
266
+ The depth check measures, from the pixels of a screenshot, whether each raised part looks raised at phone size (390 px wide, device scale 3). It fails naming the theme, the part, the measure, the value and the threshold.
267
+
268
+ ```ts
269
+ import { partsPage, measureParts, checkDepth } from '@supersuit/components/check/depth'
270
+
271
+ const html = partsPage(themeCss, { theme: 'maison-dawn', ground: 'light' }) // one page with every raised part
272
+ const measures = measureParts(image, rects, 3) // image: { width, height, data } RGBA
273
+ const failures = checkDepth({ id: 'maison-dawn', ground: 'light' }, measures, bar)
274
+ ```
275
+
276
+ This subpath needs no PNG decoder and no browser. The browser helpers are a separate subpath, `@supersuit/components/check/depth/playwright`: `shootParts` (draw the parts page in a page and read back the picture and the rects), `depthCompare` (the flat-beside-compiled crop picture), `decodePng`, `encodePng` and the bar math. They take any page with Playwright's `setContent`, `evaluate` and `screenshot`, so they do not import Playwright. They need `pngjs`, an optional peer: install it to use that subpath.
277
+
278
+ In this repo:
279
+
280
+ ```bash
281
+ npm run check:depth # Chromium and WebKit: round 3 passes, round 1 fails, every theme; writes depth-compare/
282
+ node scripts/calibrate-depth.mjs --json # measure without judging (calibration)
283
+ ```
284
+
285
+ The default bar is `specs/brand-theme/v1/default-bar.json`. It changes only with the maintainer's yes. A brand's own `depthBar` belongs to that brand's owner.
286
+
287
+ ## The registry
288
+
289
+ The `@supersuit` registry gives the parts, the depth utilities, the themes and the sounds to any shadcn app.
290
+
291
+ ```bash
292
+ npm run registry # writes registry.json and public/r/*.json
293
+ npm run registry -- --check # exit 1 naming each output that is not current
294
+ ```
295
+
296
+ | Item | Type | What it holds |
297
+ | --- | --- | --- |
298
+ | `style` | `registry:style` | The 22 owned parts on Base UI (`registry/style/`): shadcn's `base-nova` source with our edits (`scripts/own-parts.mjs`): phone-size targets, each raised part on its depth level, lucide-react icons |
299
+ | `depth` | `registry:item` | The eleven depth utilities. They read variables that a theme item sets |
300
+ | `theme-maison-dawn`, `theme-maison-night`, `theme-garden` | `registry:theme` | The compiler's item for each record |
301
+ | `sounds` | `registry:lib` | `install-sounds.ts`, which installs `@supersuit/components/sound` (`^0.2.0`) |
302
+
303
+ Every item that uses a depth class depends on `depth`. The build refuses an item whose record or file is missing, names it, and writes nothing.
304
+
305
+ The registry is built here, on this computer. Its home is `https://components.supersuit.co`, and that host serves it only after its first deploy. Until then, `npx shadcn add` works only against a local copy of `public/r/`.
306
+
307
+ ## Develop
308
+
309
+ ```bash
310
+ npm install
311
+ npm test # vitest and testing-library: every component, plus the library's shape
312
+ npm run build # dist/, checked by scripts/check-dist.mjs
313
+ npm run check:consumer # packs the tarball, installs it under .tmp/, imports each subpath
314
+ bash scripts/mutate.sh # breaks each voice-field rule on purpose; every line must say "caught"
315
+ npx vite demo/voice-field # the five states, live, in both themes
316
+ npx vite demo/app-shell # also demo/row, demo/choice-chips, demo/page-header: every state, both themes
317
+ ```
318
+
319
+ ## Contributing
320
+
321
+ ### Adding a component
322
+
323
+ 1. **Spec first.** Write `specs/<name>/SPEC.md`: its states, sizes, behaviour, words and Maison tokens.
324
+ 2. **Mockup next.** Put the mockup beside the spec, as an image and its HTML source, every state in both themes.
325
+ 3. **Get the maintainer's approval.** Write the approval date into the spec and the mockup's file name. No code before this.
326
+ 4. **Then the code.** Build `src/<name>/` with an `index.ts`, and a `styles.css` if it has styles.
327
+ 5. **Write the conformance test.** `test/<name>/conformance.test.tsx` renders every state the spec names.
328
+ 6. **Wire it in.** Add `<name>` to `components` in `src/index.ts`, and add `./<name>` (and `./<name>/styles.css`) to `exports` in `package.json`.
329
+ 7. **Run `npm run check`.** `test/library.test.ts` fails until steps 1, 2, 5 and 6 are done.
330
+
331
+ A change to an approved component changes its spec and mockup first, with the maintainer's approval, then the code.
332
+
333
+ ### Releasing
334
+
335
+ Bump the version in `package.json`, add the CHANGELOG entry, commit, then push a tag: `git tag vX.Y.Z && git push origin vX.Y.Z`. GitHub Actions publishes through npm trusted publishing (OIDC). No token is stored anywhere. See `.github/workflows/publish.yml`.
336
+
337
+ ## License
338
+
339
+ MIT
@@ -0,0 +1,116 @@
1
+ #!/usr/bin/env node
2
+ // supersuit-theme: compile a brand-theme/v1 record. Exit 0 done, 1 refused or different (--check), 2 usage.
3
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'
4
+ import { dirname, join, resolve } from 'node:path'
5
+ import { fileURLToPath } from 'node:url'
6
+
7
+ const here = dirname(fileURLToPath(import.meta.url))
8
+ // The spec has no public URL yet: it ships in this package, beside the bin.
9
+ const SPEC = join(here, '..', 'specs', 'brand-theme', 'v1', 'SPEC.md')
10
+ const HELP = `supersuit-theme build <record> [--out <dir>] [--flat] [--only depth] [--scope <selector>]
11
+ [--map <role>=<css value>]... [--check] [--json]
12
+
13
+ Compile a brand-theme/v1 record into three files:
14
+ <id>.css the variables and the depth utilities
15
+ <id>.registry.json a shadcn registry:theme item
16
+ <id>.sounds.json the sound recipe
17
+ --flat writes round 1 (every depth setting at zero) as <id>.flat.*; --only depth writes only the depth
18
+ variables and --raised, no colour roles and no utilities, as <id>.depth.*.
19
+ The spec: ${SPEC} (no public URL yet)
20
+
21
+ --out <dir> where to write (default: the current folder)
22
+ --scope <sel> the selector the variables sit under (default .theme-<id>, [data-theme="<id>"])
23
+ --map role=value an extra variable inside the scope, repeatable (--map primary=var(--color-primary))
24
+ --check write nothing; exit 1 naming each output that is not what build would write
25
+ --json print the result as JSON
26
+
27
+ Exit codes: 0 done, 1 refused record or an output differs, 2 usage.`
28
+
29
+ async function loadTheme() {
30
+ const built = join(here, '..', 'dist', 'theme', 'index.js')
31
+ if (existsSync(built)) return import(built)
32
+ return import(join(here, '..', 'src', 'theme', 'index.ts'))
33
+ }
34
+
35
+ function usage(words) {
36
+ process.stderr.write(`supersuit-theme: ${words}\n\n${HELP}\n`)
37
+ process.exit(2)
38
+ }
39
+
40
+ const argv = process.argv.slice(2)
41
+ if (argv.includes('--help') || argv.includes('-h')) {
42
+ process.stdout.write(HELP + '\n')
43
+ process.exit(0)
44
+ }
45
+ const [cmd, record, ...rest] = argv
46
+ if (cmd !== 'build') usage(cmd ? `unknown command "${cmd}"` : 'no command')
47
+ if (!record || record.startsWith('--')) usage('no record named')
48
+
49
+ const o = { out: '.', flat: false, only: undefined, scope: undefined, map: {}, check: false, json: false }
50
+ for (let i = 0; i < rest.length; i++) {
51
+ const a = rest[i]
52
+ const val = () => {
53
+ const v = rest[++i]
54
+ if (v === undefined) usage(`${a} needs a value`)
55
+ return v
56
+ }
57
+ if (a === '--out') o.out = val()
58
+ else if (a === '--flat') o.flat = true
59
+ else if (a === '--only') {
60
+ const v = val()
61
+ if (v !== 'depth') usage(`--only takes "depth", not "${v}"`)
62
+ o.only = v
63
+ } else if (a === '--scope') o.scope = val()
64
+ else if (a === '--map') {
65
+ const v = val()
66
+ const eq = v.indexOf('=')
67
+ if (eq < 1) usage(`--map takes <role>=<css value>, not "${v}"`)
68
+ o.map[v.slice(0, eq).replace(/^--/, '')] = v.slice(eq + 1)
69
+ } else if (a === '--check') o.check = true
70
+ else if (a === '--json') o.json = true
71
+ else usage(`unknown flag "${a}"`)
72
+ }
73
+
74
+ const { compileTheme } = await loadTheme()
75
+ let r
76
+ try {
77
+ r = JSON.parse(readFileSync(resolve(record), 'utf8'))
78
+ } catch (e) {
79
+ process.stderr.write(`supersuit-theme: cannot read ${record}: ${e.message}\n`)
80
+ process.exit(1)
81
+ }
82
+ let out
83
+ try {
84
+ out = compileTheme(r, { flat: o.flat, only: o.only, scope: o.scope, map: o.map })
85
+ } catch (e) {
86
+ if (o.json) process.stdout.write(JSON.stringify({ ok: false, refused: e.message }) + '\n')
87
+ process.stderr.write(`supersuit-theme: ${record}: ${e.message}\n`)
88
+ process.exit(1)
89
+ }
90
+
91
+ const base = `${r.id}${o.flat ? '.flat' : ''}${o.only ? '.depth' : ''}`
92
+ const files = [
93
+ [`${base}.css`, out.css],
94
+ [`${base}.registry.json`, JSON.stringify(out.registryItem, null, 2) + '\n'],
95
+ [`${base}.sounds.json`, JSON.stringify(out.sounds, null, 2) + '\n'],
96
+ ]
97
+ const dir = resolve(o.out)
98
+ const report = []
99
+ for (const [name, text] of files) {
100
+ const path = join(dir, name)
101
+ if (o.check) {
102
+ const have = existsSync(path) ? readFileSync(path, 'utf8') : null
103
+ report.push({ path, status: have === null ? 'missing' : have === text ? 'current' : 'different' })
104
+ } else {
105
+ mkdirSync(dir, { recursive: true })
106
+ writeFileSync(path, text)
107
+ report.push({ path, status: 'written' })
108
+ }
109
+ }
110
+ const bad = report.filter((f) => f.status === 'missing' || f.status === 'different')
111
+ if (o.json) process.stdout.write(JSON.stringify({ ok: bad.length === 0, files: report }, null, 2) + '\n')
112
+ else for (const f of report) process.stdout.write(`${f.status.padEnd(9)} ${f.path}\n`)
113
+ if (bad.length) {
114
+ if (!o.json) process.stderr.write(`supersuit-theme: not current: ${bad.map((f) => f.path).join(', ')}\n`)
115
+ process.exit(1)
116
+ }
@@ -0,0 +1,68 @@
1
+ import { type ElementType, type ReactNode } from 'react';
2
+ export interface ShellTile {
3
+ id: string;
4
+ name: string;
5
+ href: string;
6
+ icon: ReactNode;
7
+ /** A number, never a word from inside the tile. */
8
+ count?: number;
9
+ /** The count is something waiting on this person (filled); else it is a plain total (outlined). */
10
+ waiting?: boolean;
11
+ /** A tile from the More folder: shown at the end, under the separator, only while something in it waits. */
12
+ folder?: 'more';
13
+ /** Off for this app: not in the side menu. */
14
+ off?: boolean;
15
+ }
16
+ export interface AppShellWords {
17
+ skip: string;
18
+ emptyTitle: string;
19
+ emptyLine: (thing: string) => string;
20
+ close: string;
21
+ /** A count's screen-reader text. A plain total is read as the number alone. */
22
+ waiting: (n: number) => string;
23
+ }
24
+ export declare const defaultAppShellWords: AppShellWords;
25
+ export interface AppShellProps {
26
+ appName: string;
27
+ /** The app's mark in the side menu. Default: the first letter of its name. */
28
+ mark?: ReactNode;
29
+ /** The home's tiles, in the home's order: the same list the launcher reads. */
30
+ tiles: ShellTile[];
31
+ /** The id of the tile this screen belongs to. */
32
+ current?: string;
33
+ /** App-wide entries under the separator (Search). */
34
+ extra?: ShellTile[];
35
+ /** The signed-in person, at the foot of the side menu. */
36
+ person?: {
37
+ name: string;
38
+ initials?: string;
39
+ };
40
+ /** `single` (default): one page. `list-detail`: a list beside its open item. */
41
+ layout?: 'single' | 'list-detail';
42
+ /** The page, for a single screen. */
43
+ children?: ReactNode;
44
+ /** List and detail: the list pane, its header (a PageHeader with pane="list"), and its name. */
45
+ list?: ReactNode;
46
+ listHeader?: ReactNode;
47
+ listLabel?: string;
48
+ /** List and detail: the open item's body, its header (a PageHeader with pane="detail"), and its name. Absent: nothing open. */
49
+ detail?: ReactNode;
50
+ detailHeader?: ReactNode;
51
+ detailLabel?: string;
52
+ /** Changes when another item opens: focus then goes to the detail pane's heading. Default: detailLabel. */
53
+ detailKey?: string;
54
+ /** What the list holds, for "Pick a {thing} on the left to see it here." */
55
+ thing?: string;
56
+ /** Let this screen grow to 44rem from 768 px, inside the phone column. */
57
+ grow?: boolean;
58
+ /** The link component, e.g. Next.js `Link`. Default `a`. */
59
+ linkAs?: ElementType;
60
+ words?: Partial<AppShellWords>;
61
+ className?: string;
62
+ }
63
+ export declare function AppShell(p: AppShellProps): import("react").JSX.Element;
64
+ /** The home on a desktop: its sections side by side as columns. On a phone they stack. */
65
+ export declare function HomeColumns({ children, className }: {
66
+ children: ReactNode;
67
+ className?: string;
68
+ }): import("react").JSX.Element;