@1agh/maude 1.8.1 → 1.9.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 (73) hide show
  1. package/apps/studio/acp/bridge.ts +14 -2
  2. package/apps/studio/acp/probe.ts +51 -1
  3. package/apps/studio/api.ts +19 -4
  4. package/apps/studio/bin/_curl-local.mjs +7 -0
  5. package/apps/studio/bin/annotate.mjs +16 -7
  6. package/apps/studio/bin/read-annotations.mjs +62 -4
  7. package/apps/studio/client/app.jsx +428 -15977
  8. package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
  9. package/apps/studio/client/dialogs/command-palette.jsx +112 -0
  10. package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
  11. package/apps/studio/client/dialogs/help-modal.jsx +324 -0
  12. package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
  13. package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
  14. package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
  15. package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
  16. package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
  17. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
  18. package/apps/studio/client/hooks/use-project-data.jsx +90 -0
  19. package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
  20. package/apps/studio/client/hooks/use-tabs.jsx +723 -0
  21. package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
  22. package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
  23. package/apps/studio/client/inspector/color-picker.jsx +196 -0
  24. package/apps/studio/client/inspector/color.js +92 -0
  25. package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
  26. package/apps/studio/client/inspector/css-vocab.jsx +131 -0
  27. package/apps/studio/client/inspector/ds-tokens.js +90 -0
  28. package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
  29. package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
  30. package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
  31. package/apps/studio/client/inspector/layers.jsx +322 -0
  32. package/apps/studio/client/inspector/selection.js +65 -0
  33. package/apps/studio/client/inspector/token-popover.jsx +301 -0
  34. package/apps/studio/client/menus/menubar.jsx +856 -0
  35. package/apps/studio/client/selection-scope.js +40 -0
  36. package/apps/studio/client/shell/banners.jsx +272 -0
  37. package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
  38. package/apps/studio/client/shell/comments-panel.jsx +177 -0
  39. package/apps/studio/client/shell/constants.js +60 -0
  40. package/apps/studio/client/shell/dock.jsx +131 -0
  41. package/apps/studio/client/shell/icons.jsx +370 -0
  42. package/apps/studio/client/shell/status-bar.jsx +215 -0
  43. package/apps/studio/client/shell/util.js +332 -0
  44. package/apps/studio/client/shell/viewport.jsx +254 -0
  45. package/apps/studio/client/system/system-view.jsx +255 -0
  46. package/apps/studio/client/tree/tree.jsx +1243 -0
  47. package/apps/studio/comments-overlay.tsx +6 -4
  48. package/apps/studio/config.schema.json +5 -0
  49. package/apps/studio/context.ts +13 -0
  50. package/apps/studio/dist/client.bundle.js +1337 -1337
  51. package/apps/studio/dist/comment-mount.js +2 -2
  52. package/apps/studio/exporters/_browser-bundles.ts +21 -2
  53. package/apps/studio/exporters/jobs.ts +75 -15
  54. package/apps/studio/exporters/scope.ts +15 -12
  55. package/apps/studio/format.ts +296 -0
  56. package/apps/studio/http.ts +213 -23
  57. package/apps/studio/server.ts +118 -29
  58. package/apps/studio/sync/accepted-link.ts +6 -0
  59. package/apps/studio/sync/agent.ts +9 -1
  60. package/apps/studio/sync/cold-start-apply.ts +29 -4
  61. package/apps/studio/sync/cold-start.ts +78 -0
  62. package/apps/studio/sync/file-plane.ts +61 -1
  63. package/apps/studio/sync/format-sync.ts +160 -0
  64. package/apps/studio/sync/index.ts +134 -10
  65. package/apps/studio/sync/journal-client.ts +25 -5
  66. package/apps/studio/sync/migrate-seed.ts +8 -1
  67. package/apps/studio/sync/status.ts +2 -0
  68. package/apps/studio/sync/transaction-client.ts +130 -13
  69. package/apps/studio/ui-prefs.ts +95 -10
  70. package/apps/studio/whats-new.json +9 -0
  71. package/apps/studio/ws.ts +19 -4
  72. package/cli/bin/claude-design-server.mjs +0 -0
  73. package/package.json +10 -8
@@ -0,0 +1,254 @@
1
+ // shell/viewport.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
+
3
+ import { useEffect, useRef, useState } from 'react';
4
+ import { canvasUrl } from '../canvas-url.js';
5
+ import { MDCC_VERSION, SYSTEM_TAB } from './constants.js';
6
+ import { FilePreview, sanitizeDisplayText } from '../panels/file-preview.jsx';
7
+ import { basename, previewKind } from './util.js';
8
+ import { Kbd } from './icons.jsx';
9
+ import { isNativeApp } from '../github.js';
10
+ import { SystemView } from '../system/system-view.jsx';
11
+
12
+ export function Viewport({
13
+ tabs,
14
+ activePath,
15
+ registerIframe,
16
+ systemData,
17
+ onOpenFromSystem,
18
+ onSelectDs,
19
+ project,
20
+ cfg,
21
+ loadingPath,
22
+ onIframeLoad,
23
+ canvasError,
24
+ canvasReloadNonce,
25
+ onRetryCanvasLoad,
26
+ loadedPath,
27
+ showQuickSetup,
28
+ onStartQuickSetup,
29
+ previewPath,
30
+ }) {
31
+ // feature-studio-file-preview (a11y fix) — a11y-auditor found the preview
32
+ // overlay gave keyboard/AT users no signal anything happened: the click
33
+ // stayed on the (unrelated) tree row, nothing was announced, and the
34
+ // scrollable region itself wasn't in the tab order. Moving focus onto the
35
+ // region on open covers all three: it's a real focus change (AT announces
36
+ // the new `role="region"` + its label), and a focused element with
37
+ // `overflow: auto` is keyboard-scrollable (arrow/Page keys) without a
38
+ // separate tabIndex fix.
39
+ const previewRef = useRef(null);
40
+ useEffect(() => {
41
+ if (previewPath) previewRef.current?.focus();
42
+ }, [previewPath]);
43
+ // An open canvas keeps the URL it was opened with. The capability in it is
44
+ // re-minted on a timer (canvas-url.js); letting that change the `src` of a
45
+ // live iframe would reload every open canvas every few minutes. The fresh
46
+ // capability reaches an open canvas by message instead, and a frame that is
47
+ // (re)created — a new tab, a Retry, a config change — is built with it.
48
+ // Only while the frame is open: a closed tab reopened later is a new frame
49
+ // and must not inherit a capability that may have expired meanwhile.
50
+ const srcCache = useRef(new Map());
51
+ const openPaths = new Set(tabs.map((t) => t.path));
52
+ for (const [key, entry] of srcCache.current) {
53
+ if (!openPaths.has(entry.path)) srcCache.current.delete(key);
54
+ }
55
+ const stableSrc = (path) => {
56
+ const bare = canvasUrl(path, { ...cfg, canvasToken: undefined });
57
+ const key = `${path}#${canvasReloadNonce}|${bare}`;
58
+ let entry = srcCache.current.get(key);
59
+ if (!entry) {
60
+ entry = { path, src: canvasUrl(path, cfg) };
61
+ srcCache.current.set(key, entry);
62
+ }
63
+ return entry.src;
64
+ };
65
+ // One observable word for "what is the canvas pane actually doing" — the
66
+ // top-frame signal the #115 E2E scenario waits on, and the only place these
67
+ // three states are named together. `ready` is `dgn:'loaded'`-backed, so it
68
+ // cannot be faked by a timer expiring (which is exactly how the bug used to
69
+ // look successful: skeleton gone, pane white).
70
+ const canvasState =
71
+ canvasError && canvasError.path === activePath
72
+ ? 'error'
73
+ : activePath && activePath !== SYSTEM_TAB && loadedPath === activePath
74
+ ? 'ready'
75
+ : loadingPath && loadingPath === activePath
76
+ ? 'loading'
77
+ : 'idle';
78
+ return (
79
+ <div className="viewport st-stage" data-tour="viewport" data-canvas-state={canvasState}>
80
+ {previewPath && (
81
+ // feature-studio-file-preview — an overlay, not a tab: the canvas
82
+ // iframe (if any) stays mounted underneath so switching back to it
83
+ // is instant and never remounts. previewPath is intentionally never
84
+ // written into `tabs`/`activePath` (see App()'s onPreview).
85
+ <div
86
+ ref={previewRef}
87
+ className="st-file-preview-overlay"
88
+ role="region"
89
+ aria-label={`Preview: ${sanitizeDisplayText(basename(previewPath))}`}
90
+ tabIndex={0}
91
+ >
92
+ <FilePreview path={previewPath} kind={previewKind(basename(previewPath))} />
93
+ </div>
94
+ )}
95
+ {tabs.length === 0 && !previewPath && (
96
+ <div className="st-empty">
97
+ <div className="st-empty-brand">
98
+ <span className="st-brand-mark">
99
+ <svg viewBox="0 0 32 32" width="100%" height="100%" fill="none" aria-hidden="true"><path d="M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z" fill="currentColor" /></svg>
100
+ </span>
101
+ <span className="st-empty-wm">maude</span>
102
+ <span className="st-empty-sub st-mono">
103
+ CANVAS · {(project || 'MAUDE').toUpperCase()} / v{MDCC_VERSION} /
104
+ localhost:{typeof window !== 'undefined' ? window.location.port : '4399'}
105
+ </span>
106
+ </div>
107
+ <div className="st-empty-title">Nothing open yet</div>
108
+ <div className="st-empty-body">
109
+ ← Pick a screen from the list on the left, or open <strong>Design system</strong> above
110
+ it to see your colors, type, and components.
111
+ <br />
112
+ <br />
113
+ <strong>To select something on the canvas:</strong> hold <Kbd>⌘</Kbd> and hover to
114
+ preview an element, click to select it — <Kbd>⌘⇧</Kbd>+click selects more than one.
115
+ Right-click for more options.
116
+ {isNativeApp() ? (
117
+ <>
118
+ <br />
119
+ <br />
120
+ Claude can see whatever's selected when you ask for a change in the Assistant
121
+ panel, so pointing is often faster than describing it.
122
+ </>
123
+ ) : null}
124
+ </div>
125
+ {showQuickSetup && (
126
+ <button
127
+ type="button"
128
+ data-testid="st-empty-start-quick-setup"
129
+ className="btn btn--primary st-empty-quick-setup"
130
+ onClick={onStartQuickSetup}
131
+ >
132
+ Start quick setup
133
+ </button>
134
+ )}
135
+ </div>
136
+ )}
137
+ {tabs.map((t) => {
138
+ if (t.path === SYSTEM_TAB) {
139
+ return (
140
+ <div key={t.path} className={'system-view' + (t.path === activePath ? ' active' : '')}>
141
+ <SystemView
142
+ data={systemData}
143
+ onOpen={onOpenFromSystem}
144
+ cfg={cfg}
145
+ onSelectDs={onSelectDs}
146
+ />
147
+ </div>
148
+ );
149
+ }
150
+ return (
151
+ <iframe
152
+ // The nonce is part of the key ONLY so the #115 Retry can force a
153
+ // remount; it is otherwise constant, so normal switching keys on the
154
+ // path exactly as before.
155
+ key={`${t.path}#${canvasReloadNonce}`}
156
+ ref={(el) => registerIframe(t.path, el)}
157
+ src={stableSrc(t.path)}
158
+ title={`Canvas: ${t.path}`}
159
+ className={t.path === activePath ? 'active' : ''}
160
+ data-path={t.path}
161
+ data-testid={t.path === activePath ? 'canvas-frame' : undefined}
162
+ onLoad={() => onIframeLoad?.(t.path)}
163
+ // T2 (9.1-A) — only sandbox + delegate clipboard when the canvas is
164
+ // served cross-origin (canvasOrigin present = the split is on). In
165
+ // the default same-origin mode these attrs are omitted so behavior
166
+ // is identical to pre-9.1. allow-same-origin gives the cross-origin
167
+ // frame its OWN origin (own WS/fetch/storage), NOT the parent's.
168
+ {...(cfg?.canvasOrigin
169
+ ? { sandbox: 'allow-scripts allow-same-origin', allow: 'clipboard-write' }
170
+ : {})}
171
+ />
172
+ );
173
+ })}
174
+ {loadingPath && loadingPath === activePath && (
175
+ // DS skeletons recipe — calm .skel pulse while the canvas-shell compiles
176
+ // the TSX. Cleared by the iframe's dgn:'loaded' message (or the onLoad
177
+ // fallback timer for legacy .html canvases that never post it).
178
+ <CanvasLoading key={loadingPath} path={loadingPath} cloud={!!cfg?.cloud} />
179
+ )}
180
+ {canvasError && canvasError.path === activePath && (
181
+ // issue #115 — what the blank pane used to be. Names which of the two
182
+ // failures happened and offers the recovery that used to require
183
+ // quitting the app (or knowing that switching projects and back
184
+ // re-reads /_config).
185
+ <div className="st-canvas-error" role="alert" data-testid="canvas-load-error">
186
+ <div className="st-canvas-error-card">
187
+ <div className="st-canvas-error-title">
188
+ {canvasError.kind === 'server'
189
+ ? "Maude's server isn't responding"
190
+ : "This canvas didn't finish loading"}
191
+ </div>
192
+ <div className="st-canvas-error-body">
193
+ {canvasError.kind === 'server' ? (
194
+ <>
195
+ The canvas couldn't be reached. This usually means Maude's
196
+ server restarted underneath this window — your files on disk
197
+ are untouched.
198
+ </>
199
+ ) : (
200
+ <>
201
+ The server is up, but{' '}
202
+ <code>{sanitizeDisplayText(basename(canvasError.path))}</code>{' '}
203
+ never finished compiling. Its own error, if it has one, is in
204
+ the canvas frame.
205
+ </>
206
+ )}
207
+ </div>
208
+ <button
209
+ type="button"
210
+ className="btn btn--primary"
211
+ data-testid="canvas-load-retry"
212
+ onClick={() => onRetryCanvasLoad?.(canvasError.path)}
213
+ >
214
+ Reload canvas
215
+ </button>
216
+ </div>
217
+ </div>
218
+ )}
219
+ </div>
220
+ );
221
+ }
222
+
223
+ // The canvas loading screen. OPAQUE on purpose: until the canvas reports
224
+ // `canvas-rendered` the frame underneath is the bare shell — a white page,
225
+ // and on a canvas with comments, pins floating over nothing — which reads as
226
+ // "something broke". The card fades in after a beat so a warm canvas that
227
+ // renders in a few hundred ms never flashes it; the hint after a few seconds
228
+ // says why a cold canvas is slow instead of leaving the user to wonder.
229
+ export function CanvasLoading({ path, cloud }) {
230
+ const [slow, setSlow] = useState(false);
231
+ useEffect(() => {
232
+ const t = setTimeout(() => setSlow(true), 4000);
233
+ return () => clearTimeout(t);
234
+ }, []);
235
+ const name = sanitizeDisplayText(basename(path || '').replace(/\.(tsx|jsx|html?)$/i, ''));
236
+ return (
237
+ <div className="st-canvas-loading" role="status" aria-live="polite" data-testid="canvas-loading">
238
+ <div className="st-skel-card">
239
+ <div className="st-canvas-loading-head">
240
+ <span className="st-canvas-loading-spinner" aria-hidden="true" />
241
+ <span className="st-canvas-loading-title">Opening {name}…</span>
242
+ </div>
243
+ <span className="skel st-skel-thumb" aria-hidden="true" />
244
+ <span className="skel st-skel-line" style={{ width: '72%' }} aria-hidden="true" />
245
+ <span className="skel st-skel-line" style={{ width: '46%' }} aria-hidden="true" />
246
+ <div className={'st-canvas-loading-hint' + (slow ? ' is-shown' : '')}>
247
+ {cloud
248
+ ? 'Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.'
249
+ : 'Still working — large canvases take a moment to build.'}
250
+ </div>
251
+ </div>
252
+ </div>
253
+ );
254
+ }
@@ -0,0 +1,255 @@
1
+ // system/system-view.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
+
3
+ import { canvasUrl } from '../canvas-url.js';
4
+
5
+ // ---------- SystemView ----------
6
+ //
7
+ // DDR-048 — the System view renders the USER's design-system tokens. It does
8
+ // NOT read from `document.documentElement` (that would surface the dev-server
9
+ // shell's amber-rust chrome theme from styles/1-tokens.css, which is NOT a
10
+ // user template) and it does NOT assume any canonical token-name contract.
11
+ // Whatever the user's `colors_and_type.css` declared — names, values, theme
12
+ // blocks — is what shows up here.
13
+
14
+ // Order kinds match the typical reading flow of a tokens file. Unknown kinds
15
+ // fall through to `other` so a custom token group still renders, just last.
16
+ export const TOKEN_GROUP_ORDER = [
17
+ 'color',
18
+ 'space',
19
+ 'radius',
20
+ 'shadow',
21
+ 'leading',
22
+ 'weight',
23
+ 'motion',
24
+ 'font',
25
+ 'other',
26
+ ];
27
+
28
+ export const TOKEN_GROUP_LABELS = {
29
+ color: 'colors',
30
+ space: 'spacing',
31
+ radius: 'radii',
32
+ shadow: 'shadows',
33
+ leading: 'leading',
34
+ weight: 'weights',
35
+ motion: 'motion',
36
+ font: 'font stacks',
37
+ other: 'other',
38
+ };
39
+
40
+ export function isSwatchKind(kind) {
41
+ return kind === 'color';
42
+ }
43
+
44
+ export function TokenLadder({ tokens, tokenGroups, tokensPath }) {
45
+ if (!tokens || tokens.length === 0) {
46
+ return (
47
+ <section className="sv-section sv-section-tokens">
48
+ <h2>
49
+ tokens<span className="sv-h-num">0</span>
50
+ </h2>
51
+ <div className="sv-empty">
52
+ <p>
53
+ No tokens parsed from{' '}
54
+ {tokensPath ? <code>{tokensPath}</code> : 'the configured tokens file'}. Does the file
55
+ exist and contain CSS custom properties (<code>--name: value;</code>)?
56
+ </p>
57
+ </div>
58
+ </section>
59
+ );
60
+ }
61
+
62
+ const groups = tokenGroups || {};
63
+ const kinds = Array.from(new Set([...TOKEN_GROUP_ORDER, ...Object.keys(groups)])).filter(
64
+ (k) => groups[k]?.length
65
+ );
66
+
67
+ return (
68
+ <>
69
+ {kinds.map((kind) => {
70
+ const list = groups[kind];
71
+ const swatch = isSwatchKind(kind);
72
+ return (
73
+ <section className={'sv-section sv-section-tokens sv-section-' + kind} key={kind}>
74
+ <h2>
75
+ tokens · {TOKEN_GROUP_LABELS[kind] || kind}
76
+ <span className="sv-h-num">{list.length}</span>
77
+ </h2>
78
+ <div className="sv-tokens-ladder">
79
+ {list.map((t) => (
80
+ <div className="sv-tok-cell" key={t.name + '|' + t.value}>
81
+ {swatch ? (
82
+ <div className="sv-tok-swatch" style={{ background: t.value }} />
83
+ ) : null}
84
+ <div className="sv-tok-meta">
85
+ <code className="sv-tok-name">{t.name}</code>
86
+ <span className="sv-tok-value">{t.value || '—'}</span>
87
+ </div>
88
+ </div>
89
+ ))}
90
+ </div>
91
+ </section>
92
+ );
93
+ })}
94
+ </>
95
+ );
96
+ }
97
+
98
+ // Find a leading partner by name suffix: --fs-base → --lh-base, --type-xl → --lh-xl.
99
+ // Returns null when no convention match exists; caller omits the lineHeight style.
100
+ export function findLeadingFor(typeToken, leadingTokens) {
101
+ const m = typeToken.name.match(/^--(?:type|fs|text)-(.+)$/);
102
+ if (!m) return null;
103
+ const suffix = m[1];
104
+ return (
105
+ (leadingTokens || []).find(
106
+ (t) => /^--(?:lh|leading|line-height)-/.test(t.name) && t.name.endsWith('-' + suffix)
107
+ )?.value ?? null
108
+ );
109
+ }
110
+
111
+ // Best-effort sample font: prefer body / sans / display tokens, fall back to
112
+ // the first font-kind token, fall back to system-ui. Avoids the shell's
113
+ // Berkeley Mono leaking into user-facing previews.
114
+ export function sampleFontFamily(fontTokens) {
115
+ if (!fontTokens?.length) return undefined;
116
+ const prefer = ['body', 'sans', 'display', 'text', 'family'];
117
+ for (const tag of prefer) {
118
+ const hit = fontTokens.find((t) => t.name.includes(tag));
119
+ if (hit) return hit.value;
120
+ }
121
+ return fontTokens[0].value;
122
+ }
123
+
124
+ export function TypeLadder({ tokenGroups }) {
125
+ const typeTokens = tokenGroups?.fontsize || [];
126
+ if (typeTokens.length === 0) return null;
127
+ const leadingTokens = tokenGroups?.leading || [];
128
+ const sampleFont = sampleFontFamily(tokenGroups?.font);
129
+
130
+ return (
131
+ <section className="sv-section sv-section-type">
132
+ <h2>
133
+ type · ladder<span className="sv-h-num">{typeTokens.length}</span>
134
+ </h2>
135
+ <div className="sv-type-list">
136
+ {typeTokens.map((t) => {
137
+ const lh = findLeadingFor(t, leadingTokens);
138
+ const style = { fontSize: t.value };
139
+ if (lh) style.lineHeight = lh;
140
+ if (sampleFont) style.fontFamily = sampleFont;
141
+ return (
142
+ <div className="sv-type-row" key={t.name}>
143
+ <code className="sv-type-tok">{t.name}</code>
144
+ <span className="sv-type-sample" style={style}>
145
+ The catalog is the system.
146
+ </span>
147
+ </div>
148
+ );
149
+ })}
150
+ </div>
151
+ </section>
152
+ );
153
+ }
154
+
155
+ export function SystemView({ data, onOpen, cfg, onSelectDs }) {
156
+ if (!data) {
157
+ return (
158
+ <div className="sv-empty">
159
+ <p>Loading design system…</p>
160
+ </div>
161
+ );
162
+ }
163
+ const {
164
+ previewGallery,
165
+ uiKitsGallery,
166
+ systemDir,
167
+ tokens,
168
+ tokenGroups,
169
+ tokensPath,
170
+ ds,
171
+ availableDesignSystems,
172
+ } = data;
173
+ const empty =
174
+ (!previewGallery || !previewGallery.length) && (!uiKitsGallery || !uiKitsGallery.length);
175
+ const hasPicker = Array.isArray(availableDesignSystems) && availableDesignSystems.length > 1;
176
+ const selectedName = ds?.name ?? availableDesignSystems?.[0]?.name ?? '';
177
+
178
+ return (
179
+ <div className="sv">
180
+ <header className="sv-header">
181
+ <span className="sv-sku">MAUDE-DSN/01</span>
182
+ <span className="sv-title">design system view</span>
183
+ {hasPicker ? (
184
+ <label className="sv-ds-picker">
185
+ <span className="sv-ds-picker-label">DS</span>
186
+ <select value={selectedName} onChange={(e) => onSelectDs && onSelectDs(e.target.value)}>
187
+ {availableDesignSystems.map((d) => (
188
+ <option key={d.name} value={d.name}>
189
+ {d.name}
190
+ </option>
191
+ ))}
192
+ </select>
193
+ </label>
194
+ ) : null}
195
+ <span className="sv-loc">
196
+ <code>{systemDir}</code>
197
+ </span>
198
+ </header>
199
+
200
+ {ds?.description ? <p className="sv-ds-description">{ds.description}</p> : null}
201
+
202
+ <TokenLadder tokens={tokens} tokenGroups={tokenGroups} tokensPath={tokensPath} />
203
+ <TypeLadder tokenGroups={tokenGroups} />
204
+
205
+ {empty ? (
206
+ <div className="sv-empty">
207
+ <p>
208
+ No <code>preview/</code> or <code>ui_kits/</code> folders found under{' '}
209
+ <code>{systemDir}</code>.
210
+ </p>
211
+ </div>
212
+ ) : (
213
+ <>
214
+ <Gallery
215
+ title="preview"
216
+ items={previewGallery}
217
+ onOpen={onOpen}
218
+ kind="preview"
219
+ cfg={cfg}
220
+ />
221
+ <Gallery title="ui kits" items={uiKitsGallery} onOpen={onOpen} kind="ui_kits" cfg={cfg} />
222
+ </>
223
+ )}
224
+ </div>
225
+ );
226
+ }
227
+
228
+ export function Gallery({ title, items, onOpen, kind, cfg }) {
229
+ if (!items || items.length === 0) return null;
230
+ return (
231
+ <section className="sv-section">
232
+ <h2>
233
+ {title} <span className="sv-count">{items.length}</span>
234
+ </h2>
235
+ <div className={'sv-previews sv-previews-' + kind}>
236
+ {items.map((p) => (
237
+ <article key={p.path} className="sv-preview-card" onClick={() => onOpen(p.path)}>
238
+ <div className="sv-preview-frame">
239
+ <iframe
240
+ src={canvasUrl(p.path, cfg, { thumbnail: true })}
241
+ title={p.label}
242
+ scrolling="no"
243
+ {...(cfg?.canvasOrigin ? { sandbox: 'allow-scripts allow-same-origin' } : {})}
244
+ />
245
+ </div>
246
+ <div className="sv-preview-foot">
247
+ <strong>{p.label}</strong>
248
+ <code>{p.path}</code>
249
+ </div>
250
+ </article>
251
+ ))}
252
+ </div>
253
+ </section>
254
+ );
255
+ }