@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
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // THE PAGE FRAME EVERY APP SITS IN (spec approved 2026-12-02). Below 1024 px: one phone column, at most 30rem,
4
+ // centred, with safe-area padding. From 1024 px (measured on the window): a 240 px side menu drawn from the app's
5
+ // tile list, and a wide main area holding one page (at most 52rem) or a 360 px list beside its open item. The layout
6
+ // is CSS (media queries), so it is right on the first paint in Next.js and Vite alike; the same 1024 px query, read
7
+ // in script, tells the parts inside (the page header, a sheet) which form to take.
8
+ import { useEffect, useId, useRef } from 'react';
9
+ import { ShellContext, useDesktop } from '../page-header/shell-context.js';
10
+ export const defaultAppShellWords = {
11
+ skip: 'Skip to content',
12
+ emptyTitle: 'Nothing open',
13
+ emptyLine: (thing) => `Pick a ${thing} on the left to see it here.`,
14
+ close: 'Close',
15
+ waiting: (n) => `${n} waiting`,
16
+ };
17
+ function NavItem({ t, current, Link, w }) {
18
+ const on = t.id === current;
19
+ const has = typeof t.count === 'number' && t.count > 0;
20
+ const name = has ? `${t.name}, ${t.waiting ? w.waiting(t.count) : String(t.count)}` : t.name;
21
+ return (_jsx("li", { children: _jsxs(Link, { href: t.href, className: "ss-shell-nav-link", "aria-current": on ? 'page' : undefined, "aria-label": name, children: [_jsx("span", { className: "ss-shell-nav-icon", "aria-hidden": "true", children: t.icon }), _jsx("span", { className: "ss-shell-nav-name", children: t.name }), has && _jsx("span", { className: "ss-shell-count", "data-waiting": t.waiting ? '' : undefined, "aria-hidden": "true", children: t.count })] }) }));
22
+ }
23
+ export function AppShell(p) {
24
+ const w = { ...defaultAppShellWords, ...p.words };
25
+ const desktop = useDesktop();
26
+ const Link = p.linkAs ?? 'a';
27
+ const mainId = `ss-shell-main-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
28
+ const main = useRef(null);
29
+ const detailPane = useRef(null);
30
+ const home = p.tiles.filter((t) => !t.off && t.folder !== 'more');
31
+ const folder = p.tiles.filter((t) => !t.off && t.folder === 'more' && t.waiting && (t.count ?? 0) > 0);
32
+ const after = [...(p.extra ?? []).filter((t) => !t.off), ...folder];
33
+ // Opening another item moves focus to the detail pane's heading; the list keeps its scroll position.
34
+ const key = p.detailKey ?? p.detailLabel;
35
+ const firstKey = useRef(true);
36
+ useEffect(() => {
37
+ if (firstKey.current) {
38
+ firstKey.current = false;
39
+ return;
40
+ }
41
+ if (key == null)
42
+ return;
43
+ const h = detailPane.current?.querySelector('h1, h2, h3');
44
+ if (!h)
45
+ return;
46
+ if (!h.hasAttribute('tabindex'))
47
+ h.setAttribute('tabindex', '-1');
48
+ h.focus({ preventScroll: true });
49
+ }, [key]);
50
+ const skip = (e) => { e.preventDefault(); main.current?.focus(); };
51
+ const open = p.detail != null;
52
+ const layout = p.layout ?? 'single';
53
+ return (_jsx(ShellContext.Provider, { value: { inShell: true, desktop, appName: p.appName }, children: _jsxs("div", { className: ['ss-shell', p.className].filter(Boolean).join(' '), "data-desktop": desktop ? '' : undefined, "data-grow": p.grow ? '' : undefined, children: [_jsx("a", { className: "ss-shell-skip", href: `#${mainId}`, onClick: skip, children: w.skip }), _jsxs("nav", { className: "ss-shell-side", "aria-label": p.appName, children: [_jsxs("div", { className: "ss-shell-app", children: [_jsx("span", { className: "ss-shell-mark", "aria-hidden": "true", children: p.mark ?? p.appName.slice(0, 1) }), _jsx("span", { className: "ss-shell-app-name", children: p.appName })] }), _jsx("ul", { className: "ss-shell-nav", children: home.map((t) => _jsx(NavItem, { t: t, current: p.current, Link: Link, w: w }, t.id)) }), after.length > 0 && _jsxs(_Fragment, { children: [_jsx("div", { className: "ss-shell-sep", role: "presentation" }), _jsx("ul", { className: "ss-shell-nav", children: after.map((t) => _jsx(NavItem, { t: t, current: p.current, Link: Link, w: w }, t.id)) })] }), p.person && (_jsxs("div", { className: "ss-shell-who", children: [_jsx("span", { className: "ss-shell-who-av", "aria-hidden": "true", children: p.person.initials ?? p.person.name.slice(0, 1) }), _jsx("span", { children: p.person.name })] }))] }), _jsxs("main", { ref: main, id: mainId, tabIndex: -1, className: "ss-shell-main", "data-layout": layout, children: [layout === 'single'
54
+ ? _jsx("div", { className: "ss-shell-page", children: p.children })
55
+ : (_jsxs("div", { className: "ss-shell-ld", "data-open": open ? '' : undefined, children: [_jsxs("section", { className: "ss-shell-list", "aria-label": p.listLabel, children: [p.listHeader, _jsx("div", { className: "ss-shell-list-body", children: p.list })] }), _jsx("section", { ref: detailPane, className: "ss-shell-detail", "aria-label": open ? p.detailLabel : w.emptyTitle, children: open
56
+ ? _jsxs(_Fragment, { children: [p.detailHeader, _jsx("div", { className: "ss-shell-detail-body", children: p.detail })] })
57
+ : (_jsxs("div", { className: "ss-shell-empty", children: [_jsx("span", { className: "ss-shell-empty-icon", "aria-hidden": "true", children: _jsxs("svg", { viewBox: "0 0 24 24", width: "30", height: "30", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "3" }), _jsx("path", { d: "M9 4v16" })] }) }), _jsx("b", { className: "ss-shell-empty-title", children: w.emptyTitle }), _jsx("p", { children: w.emptyLine(p.thing ?? 'item') })] })) })] })), p.children && layout === 'list-detail' ? p.children : null] })] }) }));
58
+ }
59
+ /** The home on a desktop: its sections side by side as columns. On a phone they stack. */
60
+ export function HomeColumns({ children, className }) {
61
+ return _jsx("div", { className: ['ss-shell-columns', className].filter(Boolean).join(' '), children: children });
62
+ }
@@ -0,0 +1,3 @@
1
+ export { AppShell, HomeColumns, defaultAppShellWords, type AppShellProps, type AppShellWords, type ShellTile } from './app-shell.js';
2
+ export { ShellSheet, SWIPE_CLOSE, type ShellSheetProps } from './sheet.js';
3
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY, type ShellState } from '../page-header/shell-context.js';
@@ -0,0 +1,5 @@
1
+ // @supersuit/components/app-shell: the page frame every app sits in. Import the styles once:
2
+ // import '@supersuit/components/app-shell/styles.css'
3
+ export { AppShell, HomeColumns, defaultAppShellWords } from './app-shell.js';
4
+ export { ShellSheet, SWIPE_CLOSE } from './sheet.js';
5
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY } from '../page-header/shell-context.js';
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ShellSheetProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ /** The overlay's name, drawn at its top. */
6
+ title: string;
7
+ children: ReactNode;
8
+ /** The close button's name. Default "Close". */
9
+ closeLabel?: string;
10
+ className?: string;
11
+ }
12
+ /** A drag down the grab handle past this many pixels closes the sheet. */
13
+ export declare const SWIPE_CLOSE = 80;
14
+ export declare function ShellSheet(p: ShellSheetProps): import("react").JSX.Element | null;
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // THE SHELL'S OVERLAY: a sheet that rises from the bottom on a phone, and the same content as a centred 560 px dialog
4
+ // from 1024 px. Same content, same order. Escape and a tap on the scrim close it, as a swipe down on the sheet's
5
+ // grab handle does. While open it traps focus; when it closes, focus goes back to whatever opened it.
6
+ import { useEffect, useId, useRef } from 'react';
7
+ import { useDesktop, useShell } from '../page-header/shell-context.js';
8
+ /** A drag down the grab handle past this many pixels closes the sheet. */
9
+ export const SWIPE_CLOSE = 80;
10
+ const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
11
+ export function ShellSheet(p) {
12
+ const shell = useShell();
13
+ const windowDesktop = useDesktop();
14
+ const desktop = shell.inShell ? shell.desktop : windowDesktop;
15
+ const titleId = `ss-sheet-title-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
16
+ const panel = useRef(null);
17
+ const drag = useRef(null);
18
+ useEffect(() => {
19
+ if (!p.open)
20
+ return;
21
+ const opener = document.activeElement;
22
+ const first = panel.current?.querySelector(FOCUSABLE);
23
+ (first ?? panel.current)?.focus();
24
+ return () => { if (opener && document.contains(opener))
25
+ opener.focus(); };
26
+ }, [p.open]);
27
+ if (!p.open)
28
+ return null;
29
+ const key = (e) => {
30
+ if (e.key === 'Escape') {
31
+ e.preventDefault();
32
+ p.onClose();
33
+ return;
34
+ }
35
+ if (e.key !== 'Tab')
36
+ return;
37
+ const all = [...(panel.current?.querySelectorAll(FOCUSABLE) ?? [])];
38
+ if (!all.length) {
39
+ e.preventDefault();
40
+ return;
41
+ }
42
+ const first = all[0], last = all[all.length - 1];
43
+ if (e.shiftKey && document.activeElement === first) {
44
+ e.preventDefault();
45
+ last.focus();
46
+ }
47
+ else if (!e.shiftKey && document.activeElement === last) {
48
+ e.preventDefault();
49
+ first.focus();
50
+ }
51
+ };
52
+ const down = (e) => { drag.current = e.clientY; };
53
+ const up = (e) => { if (drag.current != null && e.clientY - drag.current > SWIPE_CLOSE)
54
+ p.onClose(); drag.current = null; };
55
+ const form = desktop ? 'dialog' : 'sheet';
56
+ return (_jsxs("div", { className: "ss-sheet-layer", "data-form": form, children: [_jsx("div", { className: "ss-sheet-scrim", onClick: p.onClose }), _jsxs("div", { ref: panel, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, className: ['ss-sheet', p.className].filter(Boolean).join(' '), "data-form": form, onKeyDown: key, children: [form === 'sheet' && _jsx("div", { className: "ss-sheet-grab", "aria-hidden": "true", onPointerDown: down, onPointerUp: up }), _jsxs("div", { className: "ss-sheet-head", children: [_jsx("b", { id: titleId, className: "ss-sheet-title", children: p.title }), form === 'dialog' && (_jsx("button", { type: "button", className: "ss-sheet-close", "aria-label": p.closeLabel ?? 'Close', onClick: p.onClose, children: _jsx("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l12 12M18 6 6 18" }) }) }))] }), _jsx("div", { className: "ss-sheet-body", children: p.children })] })] }));
57
+ }
@@ -0,0 +1,112 @@
1
+ /* @supersuit/components/app-shell: the page frame every app sits in (spec approved 2026-12-02).
2
+ *
3
+ * One breakpoint: 1024 px, measured on the window (a media query), never on the device. Below it, a phone column at
4
+ * most 30rem wide, centred, with safe-area padding. From it, a 240 px side menu and a wide main area.
5
+ *
6
+ * Every colour is a theme role (--background, --card, --popover, --foreground, --muted-foreground, --border,
7
+ * --secondary, --muted, --accent-ink, --primary, --primary-foreground, --input, --scrim, --ring) and titles use
8
+ * --font-display, as a compiled brand theme names them: put `.theme-maison-dawn` or `.theme-maison-night` on any
9
+ * element above. With no theme, the Maison Dawn values are the fallbacks.
10
+ */
11
+
12
+ .ss-shell {
13
+ position: relative; box-sizing: border-box; min-height: 100vh; min-height: 100dvh;
14
+ background: var(--background, #F3E5D5); color: var(--foreground, #2A231B);
15
+ font-family: var(--font-text, "DM Sans", system-ui, sans-serif);
16
+ }
17
+ .ss-shell :focus { outline: none; }
18
+ .ss-shell :focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: 2px; }
19
+
20
+ .ss-shell-skip {
21
+ position: absolute; z-index: 50; left: 12px; top: 12px; transform: translateY(-200%);
22
+ display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
23
+ background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-weight: 600; text-decoration: none;
24
+ }
25
+ .ss-shell-skip:focus, .ss-shell-skip:focus-visible { transform: none; }
26
+
27
+ /* ---------- phone: one column ---------- */
28
+ .ss-shell-side { display: none; }
29
+ .ss-shell-main {
30
+ display: block; box-sizing: border-box; width: 100%; max-width: 30rem; margin: 0 auto;
31
+ padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
32
+ }
33
+ @media (min-width: 768px) and (max-width: 1023.98px) {
34
+ .ss-shell[data-grow] .ss-shell-main { max-width: 44rem; }
35
+ }
36
+ /* List and detail on a phone: the open item alone, or the list alone. */
37
+ .ss-shell-ld[data-open] .ss-shell-list { display: none; }
38
+ .ss-shell-ld:not([data-open]) .ss-shell-detail { display: none; }
39
+ .ss-shell-detail-body { box-sizing: border-box; padding: 0 16px 24px; }
40
+ .ss-shell-columns { display: grid; gap: 20px; }
41
+
42
+ /* ---------- the side menu ---------- */
43
+ .ss-shell-app { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); }
44
+ .ss-shell-mark { flex: none; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-family: var(--font-text, "DM Sans", system-ui, sans-serif); font-size: 14px; font-weight: 600; }
45
+ .ss-shell-app-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
46
+ .ss-shell-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
47
+ .ss-shell-nav-link {
48
+ position: relative; box-sizing: border-box; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px 0 12px;
49
+ border-radius: 10px; color: var(--foreground, #2A231B); font-size: 15px; text-decoration: none;
50
+ }
51
+ .ss-shell-nav-link:hover { background: var(--muted, #EFE4D6); }
52
+ .ss-shell-nav-link[aria-current="page"] { background: var(--secondary, #EADCC9); font-weight: 600; }
53
+ .ss-shell-nav-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-ink, #2B3B50); }
54
+ .ss-shell-nav-link:focus-visible { outline-offset: -2px; }
55
+ .ss-shell-nav-icon { flex: none; display: flex; color: var(--accent-ink, #2B3B50); }
56
+ .ss-shell-nav-icon svg { width: 20px; height: 20px; }
57
+ .ss-shell-nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
58
+ .ss-shell-count {
59
+ flex: none; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
60
+ border-radius: 11px; background: none; color: var(--muted-foreground, #665B4D); box-shadow: inset 0 0 0 1px var(--border, #D9CDBB);
61
+ font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
62
+ }
63
+ .ss-shell-count[data-waiting] { background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); box-shadow: none; }
64
+ .ss-shell-sep { height: 1px; margin: 10px 12px; background: var(--border, #D9CDBB); }
65
+ .ss-shell-who { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 14px; color: var(--muted-foreground, #665B4D); }
66
+ .ss-shell-who-av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-size: 13px; font-weight: 600; }
67
+
68
+ /* ---------- the empty detail pane ---------- */
69
+ .ss-shell-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--muted-foreground, #665B4D); }
70
+ .ss-shell-empty-icon { width: 64px; height: 64px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: var(--muted, #EFE4D6); color: var(--accent-ink, #2B3B50); }
71
+ .ss-shell-empty-title { font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-weight: var(--display-weight, 400); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); color: var(--foreground, #2A231B); }
72
+ .ss-shell-empty p { margin: 0; max-width: 22rem; font-size: 15px; }
73
+
74
+ /* ---------- the overlay: a sheet on a phone ---------- */
75
+ .ss-sheet-layer { position: fixed; inset: 0; z-index: 40; }
76
+ .ss-sheet-scrim { position: absolute; inset: 0; background: var(--scrim, rgb(42 35 27 / 0.34)); }
77
+ .ss-sheet {
78
+ position: absolute; left: 0; right: 0; bottom: 0; box-sizing: border-box; max-height: 92vh; overflow-y: auto;
79
+ padding: 8px 8px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0;
80
+ background: var(--popover, #FAF7F2); color: var(--foreground, #2A231B); box-shadow: 0 -12px 30px -16px rgb(0 0 0 / 0.35);
81
+ }
82
+ .ss-sheet-grab { width: 38px; height: 5px; margin: 4px auto 10px; border-radius: 3px; background: var(--input, #C5B399); touch-action: none; cursor: grab; }
83
+ .ss-sheet-head { display: flex; align-items: center; min-height: 44px; padding: 6px 4px 6px 16px; }
84
+ .ss-sheet-title { flex: 1; font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-weight: var(--display-weight, 400); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); }
85
+ .ss-sheet-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--foreground, #2A231B); cursor: pointer; }
86
+ .ss-sheet-close:hover { background: var(--muted, #EFE4D6); }
87
+ .ss-sheet-body { padding: 0 8px; }
88
+ /* From 1024 px, the same content as a centred dialog. */
89
+ .ss-sheet[data-form="dialog"] {
90
+ left: 50%; right: auto; top: 50%; bottom: auto; width: min(560px, calc(100vw - 32px)); max-height: 86vh; transform: translate(-50%, -50%);
91
+ padding: 8px 8px 16px; border-radius: 18px; box-shadow: 0 0 0 1px var(--border, #D9CDBB), 0 30px 60px -20px rgb(0 0 0 / 0.4);
92
+ }
93
+
94
+ /* ---------- desktop: the side menu and the main area ---------- */
95
+ @media (min-width: 1024px) {
96
+ .ss-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100vh; height: 100dvh; }
97
+ .ss-shell-side {
98
+ display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; min-height: 0; overflow-y: auto; padding: 20px 12px;
99
+ background: var(--card, #FAF7F2); border-right: 1px solid var(--border, #D9CDBB);
100
+ }
101
+ .ss-shell-main { max-width: none; margin: 0; padding: 0; min-height: 0; overflow-y: auto; }
102
+ .ss-shell-main[data-layout="list-detail"] { overflow: hidden; }
103
+ .ss-shell-page { max-width: 52rem; margin: 0 auto; padding-bottom: 32px; }
104
+ .ss-shell-ld { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; }
105
+ .ss-shell-ld .ss-shell-list, .ss-shell-ld[data-open] .ss-shell-list,
106
+ .ss-shell-ld .ss-shell-detail, .ss-shell-ld:not([data-open]) .ss-shell-detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
107
+ .ss-shell-list { border-right: 1px solid var(--border, #D9CDBB); }
108
+ .ss-shell-list-body, .ss-shell-detail { overflow-y: auto; }
109
+ .ss-shell-list-body { flex: 1; min-height: 0; }
110
+ .ss-shell-detail-body { max-width: 44rem; padding: 24px 36px; font-size: 16px; line-height: 1.6; }
111
+ .ss-shell-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 24px 32px; }
112
+ }
@@ -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
+ }>;
@@ -0,0 +1,126 @@
1
+ // The before and after crop check. For a theme it draws the button row and a card twice, flat (round 1:
2
+ // the record with every depth setting at zero) on the left and as compiled on the right, at the page's
3
+ // device scale (3 on the depth device), writes `depth-compare-<theme>.png`, and measures how much the two
4
+ // differ: the mean OKLab distance (x100) between the halves, in the 12 px band around each part.
5
+ // This is the picture Gary approved on 2026-12-01, made by code instead of by hand (the vibe check's
6
+ // tools/compare.py read round 1's bounds by hand).
7
+ import { mkdirSync, writeFileSync } from 'node:fs';
8
+ import { join } from 'node:path';
9
+ import { toOklab } from "../../theme/color.js";
10
+ import { compileTheme } from "../../theme/compile.js";
11
+ import { utilityRules } from "../../theme/compile.js";
12
+ import { decodePng, encodePng } from "./png.js";
13
+ import { readRects } from "./shoot.js";
14
+ export const CROP_BAND = 12;
15
+ const GUTTER = 16;
16
+ /** One half: a label, the button row and an Awaiting you card, drawn with the theme's depth classes. */
17
+ export function comparePage(themeCss, o) {
18
+ return `<!doctype html>
19
+ <html class="theme-${o.theme}" data-theme="${o.theme}" lang="en">
20
+ <head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
21
+ <style>
22
+ ${themeCss}
23
+ ${utilityRules('.')}
24
+ html, body { margin: 0; background: var(--background); color: var(--foreground); }
25
+ body { padding: 20px 24px 48px; font: 400 16px/1.35 var(--font-text); -webkit-font-smoothing: antialiased; }
26
+ .label { font: 600 13px/1 system-ui, sans-serif; letter-spacing: 0.02em; color: var(--muted-foreground); margin-bottom: 20px; }
27
+ .row { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 40px; }
28
+ .btn { height: 44px; padding: 0 20px; border: 0; border-radius: var(--radius); font: 500 16px/1 var(--font-text); display: inline-flex; align-items: center; justify-content: center; }
29
+ .p-primary { background-color: var(--primary); color: var(--primary-foreground); }
30
+ .p-secondary { background-color: var(--secondary); color: var(--secondary-foreground); }
31
+ .p-outline { background-color: var(--raised); color: var(--foreground); }
32
+ .card { border-radius: var(--radius); background-color: var(--card); color: var(--card-foreground); overflow: hidden; }
33
+ .card .body { padding: 16px 18px 18px; }
34
+ .chip { display: inline-block; padding: 4px 10px; border-radius: 999px; background: var(--secondary); color: var(--secondary-foreground); font-size: 13px; }
35
+ .when { margin-left: 8px; font-size: 13px; color: var(--muted-foreground); }
36
+ .title { margin: 10px 0 6px; font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: var(--display-tracking); font-size: 24px; line-height: 1.15; }
37
+ .text { margin: 0; color: var(--muted-foreground); font-size: 15px; }
38
+ .foot { display: flex; gap: 12px; padding: 16px 18px; border-top: 1px solid var(--border); }
39
+ .foot .btn { flex: 1; }
40
+ </style></head>
41
+ <body>
42
+ <div class="label">${o.label}</div>
43
+ <div class="row">
44
+ <button data-crop="primary" class="btn p-primary sheen-primary elev-primary">Main action</button>
45
+ <button data-crop="secondary" class="btn p-secondary sheen-tint elev-btn">Second</button>
46
+ <button data-crop="outline" class="btn p-outline sheen-quiet elev-btn">Outline</button>
47
+ </div>
48
+ <div data-crop="card" class="card elev-1 sheen-surface">
49
+ <div class="body">
50
+ <span class="chip">Awaiting you</span><span class="when">2 hours</span>
51
+ <p class="title">Send the pilot recap to the Harbor team</p>
52
+ <p class="text">Pluma drafted it from Tuesday's call. Four lines, the price, and the start date.</p>
53
+ </div>
54
+ <div class="foot">
55
+ <button class="btn p-primary sheen-primary elev-primary">Pluma sends it</button>
56
+ <button class="btn p-outline sheen-quiet elev-btn">Gary edits it</button>
57
+ </div>
58
+ </div>
59
+ </body></html>
60
+ `;
61
+ }
62
+ async function shootHalf(page, css, theme, label) {
63
+ await page.setContent(comparePage(css, { theme, label }), { waitUntil: 'load' });
64
+ await page.evaluate(() => document.fonts.ready.then(() => undefined));
65
+ const rects = await page.evaluate(() => {
66
+ const out = {};
67
+ document.querySelectorAll('[data-crop]').forEach((el) => {
68
+ const r = el.getBoundingClientRect();
69
+ out[el.getAttribute('data-crop')] = { x: r.x + window.scrollX, y: r.y + window.scrollY, width: r.width, height: r.height };
70
+ });
71
+ return out;
72
+ });
73
+ const { scale } = await readRects(page);
74
+ const img = decodePng(await page.screenshot({ fullPage: true, type: 'png', animations: 'disabled' }));
75
+ return { img, rects, scale };
76
+ }
77
+ /** Mean OKLab distance (x100) between two pictures over the 12 px band around each rect (CSS px). */
78
+ export function bandDiff(a, b, rects, scale, band = CROP_BAND) {
79
+ let sum = 0, n = 0;
80
+ for (const r of rects) {
81
+ const x0 = Math.max(0, Math.floor((r.x - band) * scale)), x1 = Math.min(a.width, b.width, Math.ceil((r.x + r.width + band) * scale));
82
+ const y0 = Math.max(0, Math.floor((r.y - band) * scale)), y1 = Math.min(a.height, b.height, Math.ceil((r.y + r.height + band) * scale));
83
+ const ix0 = (r.x + band) * scale, ix1 = (r.x + r.width - band) * scale, iy0 = (r.y + band) * scale, iy1 = (r.y + r.height - band) * scale;
84
+ for (let y = y0; y < y1; y++)
85
+ for (let x = x0; x < x1; x++) {
86
+ if (x >= ix0 && x < ix1 && y >= iy0 && y < iy1)
87
+ continue; // inside the face, away from its edge
88
+ const i = (y * a.width + x) * 4, j = (y * b.width + x) * 4;
89
+ const p = toOklab({ r: a.data[i], g: a.data[i + 1], b: a.data[i + 2] });
90
+ const q = toOklab({ r: b.data[j], g: b.data[j + 1], b: b.data[j + 2] });
91
+ sum += Math.hypot(p[0] - q[0], p[1] - q[1], p[2] - q[2]);
92
+ n++;
93
+ }
94
+ }
95
+ return n ? Math.round((sum / n) * 100 * 100) / 100 : 0;
96
+ }
97
+ /** Two pictures side by side with a white gutter. */
98
+ export function sideBySide(a, b, gutter) {
99
+ const width = a.width + gutter + b.width, height = Math.max(a.height, b.height);
100
+ const data = new Uint8ClampedArray(width * height * 4).fill(255);
101
+ for (const [img, ox] of [[a, 0], [b, a.width + gutter]])
102
+ for (let y = 0; y < img.height; y++)
103
+ data.set(img.data.subarray(y * img.width * 4, (y + 1) * img.width * 4), (y * width + ox) * 4);
104
+ return { width, height, data };
105
+ }
106
+ /**
107
+ * Draw `record` flat beside itself compiled, write `<outDir>/depth-compare-<id>.png`, and return the
108
+ * difference. `right: 'flat'` draws flat on both sides (the check's own failing fixture) and writes
109
+ * `depth-compare-<id>-flat-flat.png`.
110
+ */
111
+ export async function depthCompare(page, record, outDir, o = {}) {
112
+ const right = o.right ?? 'compiled';
113
+ const left = await shootHalf(page, compileTheme(record, { flat: true }).css, record.id, 'Round 1 (flat)');
114
+ const rightHalf = await shootHalf(page, compileTheme(record, { flat: right === 'flat' }).css, record.id, right === 'flat' ? 'Round 1 (flat)' : 'As compiled (depth)');
115
+ const diff = bandDiff(left.img, rightHalf.img, Object.values(left.rects), left.scale);
116
+ mkdirSync(outDir, { recursive: true });
117
+ const file = join(outDir, `depth-compare-${record.id}${right === 'flat' ? '-flat-flat' : ''}.png`);
118
+ // The picture ends 48 px under the lowest part (the page is at least a phone screen tall).
119
+ const bottom = Math.max(...Object.values(left.rects).map((r) => r.y + r.height)) + 48;
120
+ const cut = (img) => {
121
+ const height = Math.min(img.height, Math.ceil(bottom * left.scale));
122
+ return { width: img.width, height, data: img.data.subarray(0, img.width * height * 4) };
123
+ };
124
+ writeFileSync(file, encodePng(sideBySide(cut(left.img), cut(rightHalf.img), GUTTER * left.scale)));
125
+ return { file, diff };
126
+ }
@@ -0,0 +1,3 @@
1
+ export * from './measure.ts';
2
+ export * from './check.ts';
3
+ export * from './parts-page.ts';
@@ -0,0 +1,5 @@
1
+ // @supersuit/components/check/depth: the measured depth check. PNG decoding (png.ts) and the Playwright
2
+ // helpers are not exported here, so this subpath needs no decoder and no browser.
3
+ export * from "./measure.js";
4
+ export * from "./check.js";
5
+ export * from "./parts-page.js";
@@ -0,0 +1,42 @@
1
+ export type Img = {
2
+ width: number;
3
+ height: number;
4
+ data: Uint8Array | Uint8ClampedArray;
5
+ };
6
+ export type Rect = {
7
+ x: number;
8
+ y: number;
9
+ width: number;
10
+ height: number;
11
+ };
12
+ export type MeasureName = 'ledge' | 'drop' | 'top' | 'raise' | 'well' | 'pressMove' | 'pressLedge';
13
+ export type PartMeasures = Partial<Record<MeasureName, number>> & {
14
+ skipped?: Partial<Record<MeasureName, string>>;
15
+ };
16
+ export type Measures = Record<string, PartMeasures>;
17
+ export type PartKind = 'button' | 'quiet' | 'surface' | 'field';
18
+ /**
19
+ * Which measures a part takes. A name not listed is a filled button. A filled or tinted face (primary,
20
+ * a hand-drawn bg-primary button, destructive's red tint) is lit by its own colour, so `raise` is not
21
+ * asked of it; quiet buttons and surfaces are neutral faces raised off the page.
22
+ */
23
+ export declare const PART_KINDS: Record<string, PartKind>;
24
+ export declare const kindOf: (part: string, kinds?: Record<string, PartKind>) => PartKind;
25
+ /** Which measures each kind takes (`raise` is judged on dark grounds only). */
26
+ export declare const KIND_MEASURES: Record<PartKind, MeasureName[]>;
27
+ /** In CSS px. Rows below the face's bottom edge, or inside the field's top edge. */
28
+ export declare const GEOMETRY: {
29
+ readonly ledgeRow: readonly [1, 2];
30
+ readonly ledgeGround: 12;
31
+ readonly dropBand: readonly [3, 10];
32
+ readonly dropGround: 24;
33
+ readonly wellRows: readonly [1, 4];
34
+ readonly faceSides: readonly [readonly [0.06, 0.14], readonly [0.86, 0.94]];
35
+ readonly lightLimit: 99.5;
36
+ };
37
+ /** The median OKLab L (0-100) of the pixels in a CSS px box. NaN when the box is off the picture. */
38
+ export declare function bandL(img: Img, x0: number, x1: number, y0: number, y1: number, scale: number): number;
39
+ /** Measure every part in `rects` (CSS px) on `img` (device px at `scale`). */
40
+ export declare function measureParts(img: Img, rects: Record<string, Rect | Rect[]>, scale: number, o?: {
41
+ kinds?: Record<string, PartKind>;
42
+ }): Measures;