@supersuit/components 0.0.0-stage → 0.2.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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +250 -2
- package/bin/supersuit-theme.mjs +116 -0
- package/dist/check/depth/bar.d.ts +27 -0
- package/dist/check/depth/bar.js +40 -0
- package/dist/check/depth/check.d.ts +40 -0
- package/dist/check/depth/check.js +50 -0
- package/dist/check/depth/crop.d.ts +24 -0
- package/dist/check/depth/crop.js +126 -0
- package/dist/check/depth/index.d.ts +3 -0
- package/dist/check/depth/index.js +5 -0
- package/dist/check/depth/measure.d.ts +42 -0
- package/dist/check/depth/measure.js +141 -0
- package/dist/check/depth/parts-page.d.ts +6 -0
- package/dist/check/depth/parts-page.js +69 -0
- package/dist/check/depth/playwright.d.ts +4 -0
- package/dist/check/depth/playwright.js +10 -0
- package/dist/check/depth/png.d.ts +3 -0
- package/dist/check/depth/png.js +12 -0
- package/dist/check/depth/shoot.d.ts +37 -0
- package/dist/check/depth/shoot.js +30 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/sound/engine.d.ts +59 -0
- package/dist/sound/engine.js +325 -0
- package/dist/sound/index.d.ts +18 -0
- package/dist/sound/index.js +10 -0
- package/dist/sound/synth.d.ts +24 -0
- package/dist/sound/synth.js +139 -0
- package/dist/theme/color.d.ts +29 -0
- package/dist/theme/color.js +116 -0
- package/dist/theme/compile.d.ts +23 -0
- package/dist/theme/compile.js +138 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/record.d.ts +90 -0
- package/dist/theme/record.js +222 -0
- package/dist/voice-field/box-trace.d.ts +18 -0
- package/dist/voice-field/box-trace.js +87 -0
- package/dist/voice-field/index.d.ts +8 -0
- package/dist/voice-field/index.js +10 -0
- package/dist/voice-field/recorder.d.ts +71 -0
- package/dist/voice-field/recorder.js +211 -0
- package/dist/voice-field/rules.d.ts +27 -0
- package/dist/voice-field/rules.js +62 -0
- package/dist/voice-field/saved-take.d.ts +7 -0
- package/dist/voice-field/saved-take.js +66 -0
- package/dist/voice-field/store.d.ts +27 -0
- package/dist/voice-field/store.js +40 -0
- package/dist/voice-field/styles.css +161 -0
- package/dist/voice-field/toast.d.ts +13 -0
- package/dist/voice-field/toast.js +26 -0
- package/dist/voice-field/voice-field.d.ts +80 -0
- package/dist/voice-field/voice-field.js +259 -0
- package/dist/voice-field/words.d.ts +37 -0
- package/dist/voice-field/words.js +33 -0
- package/package.json +106 -4
- package/specs/brand-theme/v1/SPEC.md +130 -0
- package/specs/brand-theme/v1/default-bar.json +1196 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-12-01)
|
|
4
|
+
|
|
5
|
+
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.
|
|
6
|
+
|
|
7
|
+
### theme (`@supersuit/components/theme`) and `supersuit-theme`
|
|
8
|
+
|
|
9
|
+
- 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.
|
|
10
|
+
- `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.
|
|
11
|
+
- `supersuit-theme build <record> [--out] [--flat] [--only depth] [--scope] [--map] [--check] [--json]`. Exit 0 done, 1 refused or not current, 2 usage.
|
|
12
|
+
- Maison Dawn, Maison Night and the invented Garden theme.
|
|
13
|
+
|
|
14
|
+
### sound (`@supersuit/components/sound`)
|
|
15
|
+
|
|
16
|
+
- 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.
|
|
17
|
+
|
|
18
|
+
### check/depth (`@supersuit/components/check/depth`)
|
|
19
|
+
|
|
20
|
+
- `partsPage`, `measureParts` and `checkDepth`: the depth check from the pixels of a screenshot at phone size. It needs no PNG decoder and no browser.
|
|
21
|
+
- `@supersuit/components/check/depth/playwright`: `shootParts`, `depthCompare` (the crop picture), `decodePng`, `encodePng` and the bar math. It needs `pngjs`, now an optional peer dependency.
|
|
22
|
+
- The default bar is measured: round 1 fails and round 3 passes on all three themes, in Chromium and WebKit.
|
|
23
|
+
|
|
24
|
+
### The registry (`npm run registry`)
|
|
25
|
+
|
|
26
|
+
- `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.
|
|
27
|
+
- `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.
|
|
28
|
+
|
|
29
|
+
### Build
|
|
30
|
+
|
|
31
|
+
- `scripts/check-dist.mjs` refuses a missing subpath, and a subpath that reaches a package that is not a dependency or a peer.
|
|
32
|
+
- `npm run check:consumer` also imports `theme`, `sound` and `check/depth` from the packed tarball, and runs `supersuit-theme --help`.
|
|
33
|
+
|
|
34
|
+
## 0.1.0 (2026-11-30)
|
|
35
|
+
|
|
36
|
+
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.
|
|
37
|
+
|
|
38
|
+
### voice-field (`@supersuit/components/voice-field`)
|
|
39
|
+
|
|
40
|
+
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").
|
|
41
|
+
|
|
42
|
+
- `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/`).
|
|
43
|
+
- `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.
|
|
44
|
+
- 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.
|
|
45
|
+
- Two themes from the Maison tokens, `vf-theme-dawn` and `vf-theme-night`, styled through `--vf-*` variables, in `@supersuit/components/voice-field/styles.css`.
|
|
46
|
+
- `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,251 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @supersuit/components
|
|
2
2
|
|
|
3
|
-
|
|
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
|
+
|
|
20
|
+
`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.
|
|
21
|
+
|
|
22
|
+
## Voice field
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
**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.
|
|
27
|
+
|
|
28
|
+
### 30 seconds
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install @supersuit/components
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import '@supersuit/components/voice-field/styles.css'
|
|
36
|
+
import { useState } from 'react'
|
|
37
|
+
import { VoiceField, VoiceToasts, memoryStore } from '@supersuit/components/voice-field'
|
|
38
|
+
|
|
39
|
+
const store = memoryStore() // use an IndexedDB store in a real app (see "The store")
|
|
40
|
+
|
|
41
|
+
export function Note() {
|
|
42
|
+
const [text, setText] = useState('')
|
|
43
|
+
return (
|
|
44
|
+
<div className="vf-theme-dawn">
|
|
45
|
+
<VoiceField store={store} id="note" label="Why it matters" placeholder="Why it matters (optional)" multiline
|
|
46
|
+
value={text} onChange={setText}
|
|
47
|
+
transcribe={async (key, blob, ms) => {
|
|
48
|
+
const r = await fetch('/api/transcribe', { method: 'POST', body: blob })
|
|
49
|
+
if (r.status >= 500) throw new Error('away') // thrown: the take is kept and sent again later
|
|
50
|
+
if (!r.ok) return { refused: `status ${r.status}` } // refused: the take is kept, and the person is told
|
|
51
|
+
return { text: (await r.json()).text }
|
|
52
|
+
}}
|
|
53
|
+
onSend={() => { /* send text */ }} />
|
|
54
|
+
<VoiceToasts />
|
|
55
|
+
</div>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### The five states
|
|
61
|
+
|
|
62
|
+
1. **Empty.** A quiet mic waits inside the box.
|
|
63
|
+
2. **Recording.** The mic turns red with a stop square. Its ring grows with your voice. The time shows in the box.
|
|
64
|
+
3. **Turning speech into words.** The box is read-only, says "Writing down what you said", and shows a thin progress line. Send waits.
|
|
65
|
+
4. **Words filled in.** The heard words are added after what was typed. Send sits inside the box, beside the mic.
|
|
66
|
+
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".
|
|
67
|
+
|
|
68
|
+
`test/voice-field/conformance.test.tsx` renders each state in both themes.
|
|
69
|
+
|
|
70
|
+
### The rules it keeps
|
|
71
|
+
|
|
72
|
+
- **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.
|
|
73
|
+
- **A cancelled touch never stops a take.** The take keeps going until the next tap.
|
|
74
|
+
- **The microphone is asked for inside the press**, before anything is awaited, so iPhone Safari counts the press as the gesture.
|
|
75
|
+
- **The mic is `aria-pressed` while it records.**
|
|
76
|
+
- **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.
|
|
77
|
+
- **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)`.
|
|
78
|
+
- **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.
|
|
79
|
+
|
|
80
|
+
### Props
|
|
81
|
+
|
|
82
|
+
| Prop | What it does |
|
|
83
|
+
| --- | --- |
|
|
84
|
+
| `store` | Required. Where drafts and recordings are kept (see "The store"). |
|
|
85
|
+
| `id` | Required. Names this field's draft and kept recordings. Keep it stable across visits. |
|
|
86
|
+
| `label` | Required. The field's name, for a screen reader. The mic is "Say it: {label}". |
|
|
87
|
+
| `value`, `onChange` | The words, controlled. |
|
|
88
|
+
| `placeholder`, `multiline`, `rows`, `type`, `autoFocus` | As on any text field. `rows` opens a multiline box that many lines tall. |
|
|
89
|
+
| `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. |
|
|
90
|
+
| `onHeard({ text, ms })` | A take became words. |
|
|
91
|
+
| `onKept({ key, ms })` | The screen keeps takes itself. Without it, the field keeps them and shows them in the box. |
|
|
92
|
+
| `onHearing(bool)` | A take started or stopped being written down. |
|
|
93
|
+
| `onSend`, `sendDisabled`, `sendLabel` | Draws Send inside the box. |
|
|
94
|
+
| `persist` | Save typed words as they are typed. Default `true`. |
|
|
95
|
+
| `disabled` | Disables the mic. |
|
|
96
|
+
| `toast` | The app's own toast function, `({ id, text, tone, ms }) => void`. Default: the package's, shown by `<VoiceToasts />`. |
|
|
97
|
+
| `words` | Replace any sentence. See `VoiceFieldWords` in `src/voice-field/words.ts`. Each is a function read when it is said. |
|
|
98
|
+
| `reach` | `{ mark(up), check(force) }`: whether the transcriber can be reached. Default reads `navigator.onLine`. |
|
|
99
|
+
| `isUnreachable(e)` | Whether a thrown error means the transcriber is away (then `reach.mark(false)`). Default: every error. |
|
|
100
|
+
| `newKey()` | Makes the key a take is stored under. |
|
|
101
|
+
| `startTake` | The recording layer. Default: `@supersuit/suggest-a-change`'s, which writes each second to the store. |
|
|
102
|
+
| `status` | Show the time, the wait and the waiting note inside the box. Default `true`. |
|
|
103
|
+
| `savedTakes` | Show kept recordings in the box. Default `true`. |
|
|
104
|
+
| `Mic` | A component in place of the package's `Recorder`, for an app that wraps it with its own defaults. |
|
|
105
|
+
| `micKey` | Sets `data-key-hint` on the mic, for an app that draws a keyboard hint. |
|
|
106
|
+
| `leading` | Drawn inside the box before the words (a search magnifier). |
|
|
107
|
+
| `className`, `inputClassName`, `sendClassName`, `labelClassName` | Extra classes, for an app that draws the box with its own CSS. The label is always visually hidden. |
|
|
108
|
+
|
|
109
|
+
`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`.
|
|
110
|
+
|
|
111
|
+
### The store
|
|
112
|
+
|
|
113
|
+
The field never opens a database itself. It takes a store with two shelves, `kv` for small records and `blobs` for audio:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
interface VoiceStore {
|
|
117
|
+
get<T>(shelf: 'kv' | 'blobs', key: string): Promise<T | undefined>
|
|
118
|
+
put(shelf: 'kv' | 'blobs', key: string, value: unknown): Promise<void>
|
|
119
|
+
del(shelf: 'kv' | 'blobs', key: string): Promise<void>
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
`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.
|
|
124
|
+
|
|
125
|
+
### Themes
|
|
126
|
+
|
|
127
|
+
Two themes ship in `styles.css`. Put the class, or `data-vf-theme`, on the field or on any element above it.
|
|
128
|
+
|
|
129
|
+
| Theme | Where | Ground | To press | Focus |
|
|
130
|
+
| --- | --- | --- | --- | --- |
|
|
131
|
+
| `vf-theme-dawn` (default) | Member screens | Dawn `#F3E5D5`, card `#FAF7F2` | Navy `#22324A` | Slate `#2B3B50` |
|
|
132
|
+
| `vf-theme-night` | Artifacts pages | Night `#17171A` | Bronze `#A8834F` | Bronze |
|
|
133
|
+
|
|
134
|
+
The recording red (`#DE6152`) and the answering teal (`#58E1D1`) are the same in both.
|
|
135
|
+
|
|
136
|
+
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`.
|
|
137
|
+
|
|
138
|
+
An app with its own CSS can skip `styles.css` and pass classes instead (`className`, `classNames`). Supertools does this.
|
|
139
|
+
|
|
140
|
+
## Brand themes: `@supersuit/components/theme` and `supersuit-theme`
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
import { validateTheme, compileTheme } from '@supersuit/components/theme'
|
|
146
|
+
|
|
147
|
+
const problems = validateTheme(record) // [] when the record is good; else each field and what is wrong
|
|
148
|
+
const { css, registryItem, sounds } = compileTheme(record)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
The same from a terminal:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
npx supersuit-theme build themes/maison-dawn.theme.json --out out/ # maison-dawn.css, .registry.json, .sounds.json
|
|
155
|
+
npx supersuit-theme build themes/maison-dawn.theme.json --out out/ --check # exit 1 naming each output that is not current
|
|
156
|
+
npx supersuit-theme build themes/maison-dawn.theme.json --flat # round 1: every depth setting at zero
|
|
157
|
+
npx supersuit-theme build themes/maison-dawn.theme.json --only depth --scope 'html[data-depth="on"]'
|
|
158
|
+
npx supersuit-theme --help
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
Exit codes: 0 done, 1 a refused record or an output that differs, 2 usage.
|
|
162
|
+
|
|
163
|
+
## Sound: `@supersuit/components/sound`
|
|
164
|
+
|
|
165
|
+
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.
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
import { sound } from '@supersuit/components/sound'
|
|
169
|
+
|
|
170
|
+
sound.install(document, { recipe: theme.sounds }) // the tap listener, the audio unlock and the tap haptic
|
|
171
|
+
sound.play('success')
|
|
172
|
+
sound.haptic('success')
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
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)`.
|
|
176
|
+
|
|
177
|
+
## Depth check: `@supersuit/components/check/depth`
|
|
178
|
+
|
|
179
|
+
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.
|
|
180
|
+
|
|
181
|
+
```ts
|
|
182
|
+
import { partsPage, measureParts, checkDepth } from '@supersuit/components/check/depth'
|
|
183
|
+
|
|
184
|
+
const html = partsPage(themeCss, { theme: 'maison-dawn', ground: 'light' }) // one page with every raised part
|
|
185
|
+
const measures = measureParts(image, rects, 3) // image: { width, height, data } RGBA
|
|
186
|
+
const failures = checkDepth({ id: 'maison-dawn', ground: 'light' }, measures, bar)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
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.
|
|
190
|
+
|
|
191
|
+
In this repo:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
npm run check:depth # Chromium and WebKit: round 3 passes, round 1 fails, every theme; writes depth-compare/
|
|
195
|
+
node scripts/calibrate-depth.mjs --json # measure without judging (calibration)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
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.
|
|
199
|
+
|
|
200
|
+
## The registry
|
|
201
|
+
|
|
202
|
+
The `@supersuit` registry gives the parts, the depth utilities, the themes and the sounds to any shadcn app.
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npm run registry # writes registry.json and public/r/*.json
|
|
206
|
+
npm run registry -- --check # exit 1 naming each output that is not current
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
| Item | Type | What it holds |
|
|
210
|
+
| --- | --- | --- |
|
|
211
|
+
| `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 |
|
|
212
|
+
| `depth` | `registry:item` | The eleven depth utilities. They read variables that a theme item sets |
|
|
213
|
+
| `theme-maison-dawn`, `theme-maison-night`, `theme-garden` | `registry:theme` | The compiler's item for each record |
|
|
214
|
+
| `sounds` | `registry:lib` | `install-sounds.ts`, which installs `@supersuit/components/sound` (`^0.2.0`) |
|
|
215
|
+
|
|
216
|
+
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.
|
|
217
|
+
|
|
218
|
+
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/`.
|
|
219
|
+
|
|
220
|
+
## Develop
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
npm install
|
|
224
|
+
npm test # vitest and testing-library: every component, plus the library's shape
|
|
225
|
+
npm run build # dist/, checked by scripts/check-dist.mjs
|
|
226
|
+
npm run check:consumer # packs the tarball, installs it under .tmp/, imports each subpath
|
|
227
|
+
bash scripts/mutate.sh # breaks each voice-field rule on purpose; every line must say "caught"
|
|
228
|
+
npx vite demo/voice-field # the five states, live, in both themes
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## Contributing
|
|
232
|
+
|
|
233
|
+
### Adding a component
|
|
234
|
+
|
|
235
|
+
1. **Spec first.** Write `specs/<name>/SPEC.md`: its states, sizes, behaviour, words and Maison tokens.
|
|
236
|
+
2. **Mockup next.** Put the mockup beside the spec, as an image and its HTML source, every state in both themes.
|
|
237
|
+
3. **Get the maintainer's approval.** Write the approval date into the spec and the mockup's file name. No code before this.
|
|
238
|
+
4. **Then the code.** Build `src/<name>/` with an `index.ts`, and a `styles.css` if it has styles.
|
|
239
|
+
5. **Write the conformance test.** `test/<name>/conformance.test.tsx` renders every state the spec names.
|
|
240
|
+
6. **Wire it in.** Add `<name>` to `components` in `src/index.ts`, and add `./<name>` (and `./<name>/styles.css`) to `exports` in `package.json`.
|
|
241
|
+
7. **Run `npm run check`.** `test/library.test.ts` fails until steps 1, 2, 5 and 6 are done.
|
|
242
|
+
|
|
243
|
+
A change to an approved component changes its spec and mockup first, with the maintainer's approval, then the code.
|
|
244
|
+
|
|
245
|
+
### Releasing
|
|
246
|
+
|
|
247
|
+
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`.
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
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,27 @@
|
|
|
1
|
+
import type { Bar } from './check.ts';
|
|
2
|
+
import type { Measures } from './measure.ts';
|
|
3
|
+
export type Sample = {
|
|
4
|
+
theme: string;
|
|
5
|
+
ground: 'light' | 'dark';
|
|
6
|
+
engine: string;
|
|
7
|
+
round1: Measures;
|
|
8
|
+
round3: Measures;
|
|
9
|
+
};
|
|
10
|
+
export type MeasureSpan = {
|
|
11
|
+
lo: number;
|
|
12
|
+
hi: number;
|
|
13
|
+
threshold: number;
|
|
14
|
+
separates: boolean;
|
|
15
|
+
loAt: string;
|
|
16
|
+
hiAt: string;
|
|
17
|
+
};
|
|
18
|
+
export declare const BAR_MEASURES: readonly ["ledge", "drop", "top", "well", "pressMove", "raise"];
|
|
19
|
+
export declare const PRESS_LEDGE_OF_LEDGE = 0.5;
|
|
20
|
+
/** The threshold for one measure: the midpoint, rounded down to 0.1, so it moves toward round 1 by under 0.1. */
|
|
21
|
+
export declare function threshold(lo: number, hi: number): number;
|
|
22
|
+
export declare function spans(samples: Sample[]): Record<string, MeasureSpan>;
|
|
23
|
+
/** The light and dark bars from the measured spans. `raise` is judged on dark grounds only. */
|
|
24
|
+
export declare function barsFrom(sp: Record<string, MeasureSpan>): {
|
|
25
|
+
light: Bar;
|
|
26
|
+
dark: Bar;
|
|
27
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export const BAR_MEASURES = ['ledge', 'drop', 'top', 'well', 'pressMove', 'raise'];
|
|
2
|
+
export const PRESS_LEDGE_OF_LEDGE = 0.5;
|
|
3
|
+
/** The threshold for one measure: the midpoint, rounded down to 0.1, so it moves toward round 1 by under 0.1. */
|
|
4
|
+
export function threshold(lo, hi) {
|
|
5
|
+
const mid = (lo + hi) / 2;
|
|
6
|
+
const t = Math.floor(mid * 10) / 10;
|
|
7
|
+
return t > lo && mid - t <= (hi - lo) / 3 ? t : Math.round(mid * 100) / 100;
|
|
8
|
+
}
|
|
9
|
+
export function spans(samples) {
|
|
10
|
+
const out = {};
|
|
11
|
+
for (const k of BAR_MEASURES) {
|
|
12
|
+
let lo = -Infinity, hi = Infinity, loAt = '', hiAt = '';
|
|
13
|
+
for (const s of samples) {
|
|
14
|
+
if (k === 'raise' && s.ground !== 'dark')
|
|
15
|
+
continue;
|
|
16
|
+
for (const [part, m3] of Object.entries(s.round3)) {
|
|
17
|
+
const v1 = s.round1[part]?.[k];
|
|
18
|
+
const v3 = m3[k];
|
|
19
|
+
if (v1 !== undefined && v1 > lo) {
|
|
20
|
+
lo = v1;
|
|
21
|
+
loAt = `${s.theme} ${part} ${s.engine}`;
|
|
22
|
+
}
|
|
23
|
+
if (v3 !== undefined && v3 < hi) {
|
|
24
|
+
hi = v3;
|
|
25
|
+
hiAt = `${s.theme} ${part} ${s.engine}`;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (!Number.isFinite(lo) || !Number.isFinite(hi))
|
|
30
|
+
continue;
|
|
31
|
+
out[k] = { lo, hi, threshold: hi > lo ? threshold(lo, hi) : NaN, separates: hi > lo, loAt, hiAt };
|
|
32
|
+
}
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
35
|
+
/** The light and dark bars from the measured spans. `raise` is judged on dark grounds only. */
|
|
36
|
+
export function barsFrom(sp) {
|
|
37
|
+
const t = (k) => sp[k]?.threshold;
|
|
38
|
+
const light = { ledge: t('ledge'), drop: t('drop'), top: t('top'), well: t('well'), pressMove: t('pressMove'), pressLedgeOfLedge: PRESS_LEDGE_OF_LEDGE };
|
|
39
|
+
return { light, dark: { ...light, raise: t('raise') } };
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type Measures, type PartKind } from './measure.ts';
|
|
2
|
+
/** Thresholds in OKLab L (0-100), `pressMove` in CSS px. */
|
|
3
|
+
export type Bar = {
|
|
4
|
+
ledge: number;
|
|
5
|
+
drop: number;
|
|
6
|
+
top: number;
|
|
7
|
+
well: number;
|
|
8
|
+
pressMove: number;
|
|
9
|
+
pressLedgeOfLedge: number;
|
|
10
|
+
raise?: number;
|
|
11
|
+
};
|
|
12
|
+
/** default-bar.json: one bar per ground, plus the crop check's `diff`. */
|
|
13
|
+
export type BarFile = {
|
|
14
|
+
light: Bar;
|
|
15
|
+
dark: Bar;
|
|
16
|
+
diff?: number;
|
|
17
|
+
[k: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
export type Failure = {
|
|
20
|
+
theme: string;
|
|
21
|
+
part: string;
|
|
22
|
+
measure: string;
|
|
23
|
+
value: number;
|
|
24
|
+
threshold: number;
|
|
25
|
+
};
|
|
26
|
+
/** The parts the parts page draws, which a check expects unless told otherwise. */
|
|
27
|
+
export declare const DEFAULT_PARTS: readonly ["primary", "secondary", "outline", "destructive", "mic", "card", "field", "menu"];
|
|
28
|
+
export declare function barFor(bar: BarFile | Bar, ground: 'light' | 'dark'): Bar;
|
|
29
|
+
/**
|
|
30
|
+
* Every way `m` falls short of `bar`. A failure names the theme, the part, the measure, the value and the
|
|
31
|
+
* threshold. A part missing from `m` is a failure (`present`), never a skip. `bar: 'flat'` is a brand that
|
|
32
|
+
* is flat on purpose, with its owner's yes: nothing fails.
|
|
33
|
+
*/
|
|
34
|
+
export declare function checkDepth(theme: {
|
|
35
|
+
id: string;
|
|
36
|
+
ground: 'light' | 'dark';
|
|
37
|
+
}, m: Measures, bar: BarFile | Bar | 'flat', o?: {
|
|
38
|
+
parts?: readonly string[];
|
|
39
|
+
kinds?: Record<string, PartKind>;
|
|
40
|
+
}): Failure[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// checkDepth: hold one theme's measures to its bar. Imports nothing outside src/check/depth.
|
|
2
|
+
import { KIND_MEASURES, kindOf } from "./measure.js";
|
|
3
|
+
/** The parts the parts page draws, which a check expects unless told otherwise. */
|
|
4
|
+
export const DEFAULT_PARTS = ['primary', 'secondary', 'outline', 'destructive', 'mic', 'card', 'field', 'menu'];
|
|
5
|
+
export function barFor(bar, ground) {
|
|
6
|
+
return 'light' in bar && 'dark' in bar ? bar[ground] : bar;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Every way `m` falls short of `bar`. A failure names the theme, the part, the measure, the value and the
|
|
10
|
+
* threshold. A part missing from `m` is a failure (`present`), never a skip. `bar: 'flat'` is a brand that
|
|
11
|
+
* is flat on purpose, with its owner's yes: nothing fails.
|
|
12
|
+
*/
|
|
13
|
+
export function checkDepth(theme, m, bar, o = {}) {
|
|
14
|
+
if (bar === 'flat')
|
|
15
|
+
return [];
|
|
16
|
+
const b = barFor(bar, theme.ground);
|
|
17
|
+
const out = [];
|
|
18
|
+
const fail = (part, measure, value, threshold) => out.push({ theme: theme.id, part, measure, value, threshold });
|
|
19
|
+
const parts = o.parts ?? Object.keys(m);
|
|
20
|
+
for (const part of parts) {
|
|
21
|
+
const pm = m[part];
|
|
22
|
+
if (!pm) {
|
|
23
|
+
fail(part, 'present', 0, 1);
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
for (const k of KIND_MEASURES[kindOf(part, o.kinds)]) {
|
|
27
|
+
if (k === 'raise' && (theme.ground !== 'dark' || b.raise === undefined))
|
|
28
|
+
continue;
|
|
29
|
+
if (pm.skipped?.[k])
|
|
30
|
+
continue;
|
|
31
|
+
const v = pm[k];
|
|
32
|
+
if (k === 'pressLedge') {
|
|
33
|
+
const t = Math.round(b.ledge * b.pressLedgeOfLedge * 100) / 100;
|
|
34
|
+
if (v === undefined || !(v < t))
|
|
35
|
+
fail(part, k, v ?? NaN, t);
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
const t = b[k];
|
|
39
|
+
if (t === undefined)
|
|
40
|
+
continue;
|
|
41
|
+
if (v === undefined || !(v >= t))
|
|
42
|
+
fail(part, k, v ?? NaN, t);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const card = m.card?.drop, menu = m.menu?.drop;
|
|
46
|
+
if (parts.includes('menu') && card !== undefined && menu !== undefined && !(menu > card)) {
|
|
47
|
+
fail('menu', 'dropOverCard', Math.round((menu - card) * 100) / 100, 0);
|
|
48
|
+
}
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { BrandTheme } from '../../theme/record.ts';
|
|
2
|
+
import type { Img, Rect } from './measure.ts';
|
|
3
|
+
import { type PageLike } from './shoot.ts';
|
|
4
|
+
export declare const CROP_BAND = 12;
|
|
5
|
+
/** One half: a label, the button row and an Awaiting you card, drawn with the theme's depth classes. */
|
|
6
|
+
export declare function comparePage(themeCss: string, o: {
|
|
7
|
+
theme: string;
|
|
8
|
+
label: string;
|
|
9
|
+
}): string;
|
|
10
|
+
/** Mean OKLab distance (x100) between two pictures over the 12 px band around each rect (CSS px). */
|
|
11
|
+
export declare function bandDiff(a: Img, b: Img, rects: Rect[], scale: number, band?: number): number;
|
|
12
|
+
/** Two pictures side by side with a white gutter. */
|
|
13
|
+
export declare function sideBySide(a: Img, b: Img, gutter: number): Img;
|
|
14
|
+
/**
|
|
15
|
+
* Draw `record` flat beside itself compiled, write `<outDir>/depth-compare-<id>.png`, and return the
|
|
16
|
+
* difference. `right: 'flat'` draws flat on both sides (the check's own failing fixture) and writes
|
|
17
|
+
* `depth-compare-<id>-flat-flat.png`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function depthCompare(page: PageLike, record: BrandTheme, outDir: string, o?: {
|
|
20
|
+
right?: 'compiled' | 'flat';
|
|
21
|
+
}): Promise<{
|
|
22
|
+
file: string;
|
|
23
|
+
diff: number;
|
|
24
|
+
}>;
|