@1agh/maude 2.1.2 → 2.2.1

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.
@@ -362,10 +362,11 @@ const SEG_TITLE = {
362
362
  pages: 'One artboard at a time',
363
363
  } as const;
364
364
 
365
- /** The two homes of the switch: the canvas pill (canvas-theme-pill.tsx) and the Design system bar (ds-bar.tsx). */
365
+ /** The two homes of the switch: the canvas pill (canvas-theme-pill.tsx) and the Design system bar (ds-bar.tsx) —
366
+ * one island since #225, so one set of classes. */
366
367
  const SEG_CLASS = {
367
368
  pill: { seg: 'dc-theme-pill-seg', b: 'dc-theme-pill-b' },
368
- ds: { seg: 'ds-bar-seg', b: 'ds-bar-b' },
369
+ ds: { seg: 'dc-theme-pill-seg', b: 'dc-theme-pill-b' },
369
370
  } as const;
370
371
 
371
372
  /**
@@ -15,6 +15,9 @@
15
15
  // (smaller, grey), centred in the free band the shell reports with its `occluded-insets` (`topBand`, the stretch
16
16
  // between the project pill and the Share cluster) and never wider than it. Short of room the path line goes first,
17
17
  // then the name truncates. An older shell sends no band: the pill centres on the frame, as before.
18
+ //
19
+ // #225 — the Design system canvas's bar is the same island (`CanvasTopIsland`, its own controls on the row): it kept a
20
+ // copy of this chrome in ds/board/board.css and missed #217, so on that screen the bar sat elsewhere.
18
21
 
19
22
  import {
20
23
  type ReactNode,
@@ -30,12 +33,13 @@ import { DsIcon } from './canvas-ds-icons.tsx';
30
33
  import { getCanvasThemeSystemName, setCanvasTheme, useCanvasTheme } from './canvas-theme.ts';
31
34
  import { THEME_WORD, ThemeIcon } from './canvas-theme-icons.tsx';
32
35
 
33
- /** The pill's chrome. Kept in step with the `.ds-bar` block of ds/board/board.css (same pill, other canvases). */
36
+ /** The island's chrome — the canvas pill's AND the Design system bar's (#225: one copy, `CanvasTopIsland`). */
34
37
  const PILL_CSS = `
35
- .dc-theme-pill{position:fixed;left:50%;top:16px;translate:-50% 0;z-index:2147483000;box-sizing:border-box;display:flex;align-items:center;gap:8px;min-width:0;min-height:44px;padding:4px 8px 4px 12px;overflow:hidden;border-radius:var(--maude-hud-radius-lg,14px);background:var(--maude-hud-island-bg);color:var(--maude-chrome-fg-0);-webkit-backdrop-filter:saturate(1.4) blur(18px);backdrop-filter:saturate(1.4) blur(18px);box-shadow:var(--maude-hud-island-shadow),inset 0 0 0 .5px var(--maude-hud-island-edge);font:400 var(--maude-hud-type-sm,12px)/1 var(--maude-chrome-font-body);white-space:nowrap}
36
- .dc-theme-pill>:not(.dc-theme-pill-text){flex:none}
38
+ .dc-theme-pill{position:fixed;left:50%;top:16px;translate:-50% 0;z-index:2147483000;box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:5px;min-width:0;min-height:44px;padding:4px 8px 5px;overflow:hidden;border-radius:var(--maude-hud-radius-lg,14px);background:var(--maude-hud-island-bg);color:var(--maude-chrome-fg-0);-webkit-backdrop-filter:saturate(1.4) blur(18px);backdrop-filter:saturate(1.4) blur(18px);box-shadow:var(--maude-hud-island-shadow),inset 0 0 0 .5px var(--maude-hud-island-edge);font:400 var(--maude-hud-type-sm,12px)/1 var(--maude-chrome-font-body);white-space:nowrap}
39
+ .dc-theme-pill-row{display:flex;align-items:center;gap:8px;min-width:0;max-width:100%;padding-left:4px}
40
+ .dc-theme-pill-row>:not(.dc-theme-pill-text){flex:none}
37
41
  .dc-theme-pill-ic{display:grid;place-items:center;width:24px;height:24px;border-radius:var(--maude-hud-radius-xs,4px);background:var(--maude-hud-accent-muted);color:var(--maude-hud-accent-text)}
38
- .dc-theme-pill-text{display:flex;flex-direction:column;justify-content:center;align-items:flex-start;min-width:0;flex:0 1 auto}
42
+ .dc-theme-pill-text{display:flex;align-items:center;min-width:0;flex:0 1 auto}
39
43
  .dc-theme-pill-title{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;font-weight:600;line-height:16px}
40
44
  .dc-theme-pill-seg{display:inline-flex;margin:0 0 0 8px;min-width:0;border:0;padding:2px;border-radius:var(--maude-hud-radius-md,10px);background:var(--maude-chrome-bg-3)}
41
45
  .dc-theme-pill-seg:first-child{margin-left:0}
@@ -44,7 +48,7 @@ const PILL_CSS = `
44
48
  .dc-theme-pill-b:disabled{opacity:.4;cursor:default}
45
49
  .dc-theme-pill-b--ic{display:grid;place-items:center;padding:4px 7px}
46
50
  .dc-theme-pill-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}
47
- .dc-theme-pill-path{appearance:none;display:block;border:0;border-radius:var(--maude-hud-radius-xs,4px);padding:0 2px;margin:0 -2px;background:transparent;color:var(--maude-chrome-fg-2);font:inherit;font-size:var(--maude-hud-type-xs,11px);line-height:14px;font-family:var(--maude-chrome-font-mono,ui-monospace,monospace);text-align:left;cursor:pointer;max-width:calc(100% + 4px);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
51
+ .dc-theme-pill-path{appearance:none;display:block;border:0;border-radius:var(--maude-hud-radius-xs,4px);padding:0 4px;margin:0;background:transparent;color:var(--maude-chrome-fg-2);font:inherit;font-size:var(--maude-hud-type-2xs,10px);line-height:13px;font-family:var(--maude-chrome-font-mono,ui-monospace,monospace);text-align:center;cursor:pointer;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
48
52
  .dc-theme-pill[data-path="hidden"] .dc-theme-pill-path{position:absolute;visibility:hidden;pointer-events:none}
49
53
  .dc-theme-pill-path:hover{background:var(--maude-chrome-bg-3);color:var(--maude-chrome-fg-0)}
50
54
  .dc-theme-pill-path:focus-visible{outline:2px solid var(--maude-hud-focus-ring);outline-offset:1px}
@@ -151,33 +155,26 @@ function canvasFilePath(): string | null {
151
155
  }
152
156
 
153
157
  /**
154
- * @param bothThemes does the canvas's design system define Light AND Dark? Asked on every render (the answer can
155
- * arrive after first paint, once the system's stylesheet has parsed — the pill re-asks on load).
158
+ * #225 — the one top-centre island every canvas draws: the canvas pill below, and the Design system canvas's bar
159
+ * (ds/board/ds-bar.tsx), which used to keep its own copy of the chrome — still centred on the frame in the old one-row
160
+ * form after #217, so on that screen the bar sat elsewhere. Placed in the shell's free top band (`pillPlacement`), a
161
+ * column with the canvas's path on its own line above `children` (the host's controls row). Maude's chrome, so tagged
162
+ * `data-dc-overlay` (an export never carries it) and stepping aside while a people pill holds the spot.
156
163
  */
157
- export function CanvasThemePill({
158
- bothThemes,
159
- onProbeStale,
160
- extra,
164
+ export function CanvasTopIsland({
165
+ testid,
166
+ ariaLabel,
167
+ rowTestid,
168
+ pathTestid,
169
+ children,
161
170
  }: {
162
- bothThemes: () => boolean;
163
- /** subscribe to "the answer may have changed" (a stylesheet or the first artboard wrapper arrived) */
164
- onProbeStale?: (f: () => void) => () => void;
165
- /** 2.0.7 B2 — drawn after Light | Dark: the canvas's Canvas | Pages (canvas-pages-view.tsx) */
166
- extra?: ReactNode;
171
+ testid: string;
172
+ ariaLabel: string;
173
+ rowTestid: string;
174
+ pathTestid: string;
175
+ /** the controls row, under the path line */
176
+ children: ReactNode;
167
177
  }) {
168
- const mode = useCanvasTheme();
169
- const [, tick] = useState(0);
170
- useEffect(() => {
171
- if (typeof window === 'undefined') return;
172
- const again = () => tick((n) => n + 1);
173
- if (document.readyState === 'complete') again();
174
- else window.addEventListener('load', again, { once: true });
175
- const off = onProbeStale?.(again);
176
- return () => {
177
- window.removeEventListener('load', again);
178
- off?.();
179
- };
180
- }, [onProbeStale]);
181
178
  // r5-8 — the canvas's path on the pill; a click copies it whole and the pill says so for a moment
182
179
  const [copied, setCopied] = useState<'no' | 'ok' | 'failed'>('no');
183
180
  useEffect(() => {
@@ -197,28 +194,24 @@ export function CanvasThemePill({
197
194
  setCopied('failed');
198
195
  }
199
196
  };
200
- const both = bothThemes();
201
- const name = getCanvasThemeSystemName();
202
197
  // #217 — placed in the shell's free top band; the path line goes first when the band is short
203
198
  const band = useTopBand();
204
199
  const vw = useViewportWidth();
205
200
  const place = pillPlacement(band, vw);
206
201
  const pillRef = useRef<HTMLDivElement>(null);
207
- const textRef = useRef<HTMLSpanElement>(null);
208
- const titleRef = useRef<HTMLElement>(null);
209
202
  const pathRef = useRef<HTMLButtonElement>(null);
210
203
  const [pathShown, setPathShown] = useState(true);
211
204
  // how many characters of the path fit: it loses its leading folders first, never its file name
212
205
  const [pathChars, setPathChars] = useState(PATH_MAX);
213
- // biome-ignore lint/correctness/useExhaustiveDependencies: name, file and copied change the lines' natural widths
206
+ // file and copied change the path line's natural width; the row's own changes reach `fit` through the ResizeObserver
214
207
  useLayoutEffect(() => {
215
208
  const pill = pillRef.current;
216
209
  if (!pill) return undefined;
217
210
  const fit = () => {
218
- // the column is the only part that shrinks (the rest is flex: none), so the pill less the column is fixed
219
- const fixed =
220
- pill.getBoundingClientRect().width - (textRef.current?.getBoundingClientRect().width ?? 0);
221
- const avail = place.maxWidth - fixed;
211
+ // the path has its own line under the controls (Michal, #217): it may take the pill's whole inner width
212
+ const cs = getComputedStyle(pill);
213
+ const avail =
214
+ place.maxWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
222
215
  const btn = pathRef.current;
223
216
  let pathW = btn?.scrollWidth ?? 0;
224
217
  let chars = PATH_MAX;
@@ -231,7 +224,7 @@ export function CanvasThemePill({
231
224
  pathW = charW * shortenCanvasPath(file).length + pad;
232
225
  chars = Math.max(8, Math.min(PATH_MAX, Math.floor((avail - pad) / charW)));
233
226
  }
234
- const next = showPathLine(avail, titleRef.current?.scrollWidth ?? 0, pathW);
227
+ const next = showPathLine(avail, 0, pathW);
235
228
  setPathShown((cur) => (cur === next ? cur : next));
236
229
  setPathChars((cur) => (cur === chars ? cur : chars));
237
230
  };
@@ -240,7 +233,7 @@ export function CanvasThemePill({
240
233
  const ro = new ResizeObserver(fit); // Light | Dark and Canvas | Pages may change width after first paint
241
234
  ro.observe(pill);
242
235
  return () => ro.disconnect();
243
- }, [place.maxWidth, name, file, copied]);
236
+ }, [place.maxWidth, file, copied]);
244
237
  return (
245
238
  <>
246
239
  <style data-dc-theme-pill-css="">{PILL_CSS}</style>
@@ -248,71 +241,132 @@ export function CanvasThemePill({
248
241
  ref={pillRef}
249
242
  className="dc-theme-pill"
250
243
  data-dc-overlay=""
251
- data-testid="canvas-theme-pill"
244
+ data-testid={testid}
252
245
  data-band={place.banded ? 'band' : 'frame'}
253
246
  data-path={file ? (pathShown ? 'shown' : 'hidden') : undefined}
254
247
  style={{ left: `${place.left}px`, maxWidth: `${place.maxWidth}px` }}
255
248
  role="toolbar"
256
- aria-label="Canvas theme"
249
+ aria-label={ariaLabel}
257
250
  >
258
- {name ? (
259
- <span className="dc-theme-pill-ic" aria-hidden="true">
260
- <DsIcon name="system" size={14} />
261
- </span>
251
+ {file ? (
252
+ <button
253
+ ref={pathRef}
254
+ type="button"
255
+ className="dc-theme-pill-path"
256
+ data-testid={pathTestid}
257
+ title={`Copy relative path — ${file}`}
258
+ aria-label={`Copy relative path ${file}`}
259
+ aria-live="polite"
260
+ onClick={copyPath}
261
+ >
262
+ {copied === 'ok'
263
+ ? 'Copied'
264
+ : copied === 'failed'
265
+ ? 'Couldn’t copy'
266
+ : shortenCanvasPath(file, pathChars)}
267
+ </button>
262
268
  ) : null}
263
- {name || file ? (
264
- <span ref={textRef} className="dc-theme-pill-text" data-testid="canvas-theme-text">
265
- {name ? (
266
- <b ref={titleRef} className="dc-theme-pill-title" data-testid="canvas-theme-title">
267
- {name}
268
- </b>
269
- ) : null}
270
- {file ? (
271
- <button
272
- ref={pathRef}
273
- type="button"
274
- className="dc-theme-pill-path"
275
- data-testid="canvas-theme-path"
276
- title={`Copy relative path — ${file}`}
277
- aria-label={`Copy relative path ${file}`}
278
- aria-live="polite"
279
- onClick={copyPath}
280
- >
281
- {copied === 'ok'
282
- ? 'Copied'
283
- : copied === 'failed'
284
- ? 'Couldn’t copy'
285
- : shortenCanvasPath(file, pathChars)}
286
- </button>
287
- ) : null}
288
- </span>
289
- ) : null}
290
- <fieldset className="dc-theme-pill-seg" aria-label="Show every artboard in">
291
- {(['light', 'dark'] as const).map((m) => (
292
- <button
293
- key={m}
294
- type="button"
295
- className="dc-theme-pill-b dc-theme-pill-b--ic"
296
- data-testid={`canvas-theme-mode-${m}`}
297
- aria-pressed={mode === m}
298
- aria-label={THEME_WORD[m]}
299
- disabled={!both && mode !== m}
300
- // 2.0.7 — icons only (Michal): the name is the tooltip; a theme the canvas lacks says so there
301
- title={!both && mode !== m ? `This canvas has no ${THEME_WORD[m]}` : THEME_WORD[m]}
302
- onClick={() => setCanvasTheme(m)}
303
- >
304
- <ThemeIcon mode={m} />
305
- </button>
306
- ))}
307
- </fieldset>
308
- {!both ? (
309
- // read by a screen reader only; the greyed button's tooltip says the same to everyone else
310
- <span className="dc-theme-pill-sr" data-testid="canvas-theme-note">
311
- {`This canvas has no ${mode === 'light' ? 'Dark' : 'Light'}`}
312
- </span>
313
- ) : null}
314
- {extra}
269
+ <div className="dc-theme-pill-row" data-testid={rowTestid}>
270
+ {children}
271
+ </div>
315
272
  </div>
316
273
  </>
317
274
  );
318
275
  }
276
+
277
+ /** The design system's glyph tile and name, as both islands draw them (the name truncates first, never a control). */
278
+ export function TopIslandTitle({
279
+ name,
280
+ textTestid,
281
+ titleTestid,
282
+ }: {
283
+ name: string;
284
+ textTestid?: string;
285
+ titleTestid?: string;
286
+ }) {
287
+ return (
288
+ <>
289
+ <span className="dc-theme-pill-ic" aria-hidden="true">
290
+ <DsIcon name="system" size={14} />
291
+ </span>
292
+ <span className="dc-theme-pill-text" data-testid={textTestid}>
293
+ <b className="dc-theme-pill-title" data-testid={titleTestid}>
294
+ {name}
295
+ </b>
296
+ </span>
297
+ </>
298
+ );
299
+ }
300
+
301
+ /**
302
+ * @param bothThemes does the canvas's design system define Light AND Dark? Asked on every render (the answer can
303
+ * arrive after first paint, once the system's stylesheet has parsed — the pill re-asks on load).
304
+ */
305
+ export function CanvasThemePill({
306
+ bothThemes,
307
+ onProbeStale,
308
+ extra,
309
+ }: {
310
+ bothThemes: () => boolean;
311
+ /** subscribe to "the answer may have changed" (a stylesheet or the first artboard wrapper arrived) */
312
+ onProbeStale?: (f: () => void) => () => void;
313
+ /** 2.0.7 B2 — drawn after Light | Dark: the canvas's Canvas | Pages (canvas-pages-view.tsx) */
314
+ extra?: ReactNode;
315
+ }) {
316
+ const mode = useCanvasTheme();
317
+ const [, tick] = useState(0);
318
+ useEffect(() => {
319
+ if (typeof window === 'undefined') return;
320
+ const again = () => tick((n) => n + 1);
321
+ if (document.readyState === 'complete') again();
322
+ else window.addEventListener('load', again, { once: true });
323
+ const off = onProbeStale?.(again);
324
+ return () => {
325
+ window.removeEventListener('load', again);
326
+ off?.();
327
+ };
328
+ }, [onProbeStale]);
329
+ const both = bothThemes();
330
+ const name = getCanvasThemeSystemName();
331
+ return (
332
+ <CanvasTopIsland
333
+ testid="canvas-theme-pill"
334
+ ariaLabel="Canvas theme"
335
+ rowTestid="canvas-theme-row"
336
+ pathTestid="canvas-theme-path"
337
+ >
338
+ {name ? (
339
+ <TopIslandTitle
340
+ name={name}
341
+ textTestid="canvas-theme-text"
342
+ titleTestid="canvas-theme-title"
343
+ />
344
+ ) : null}
345
+ <fieldset className="dc-theme-pill-seg" aria-label="Show every artboard in">
346
+ {(['light', 'dark'] as const).map((m) => (
347
+ <button
348
+ key={m}
349
+ type="button"
350
+ className="dc-theme-pill-b dc-theme-pill-b--ic"
351
+ data-testid={`canvas-theme-mode-${m}`}
352
+ aria-pressed={mode === m}
353
+ aria-label={THEME_WORD[m]}
354
+ disabled={!both && mode !== m}
355
+ // 2.0.7 — icons only (Michal): the name is the tooltip; a theme the canvas lacks says so there
356
+ title={!both && mode !== m ? `This canvas has no ${THEME_WORD[m]}` : THEME_WORD[m]}
357
+ onClick={() => setCanvasTheme(m)}
358
+ >
359
+ <ThemeIcon mode={m} />
360
+ </button>
361
+ ))}
362
+ </fieldset>
363
+ {!both ? (
364
+ // read by a screen reader only; the greyed button's tooltip says the same to everyone else
365
+ <span className="dc-theme-pill-sr" data-testid="canvas-theme-note">
366
+ {`This canvas has no ${mode === 'light' ? 'Dark' : 'Light'}`}
367
+ </span>
368
+ ) : null}
369
+ {extra}
370
+ </CanvasTopIsland>
371
+ );
372
+ }
@@ -330,8 +330,16 @@
330
330
  color: var(--fg-2);
331
331
  font-variant-numeric: tabular-nums;
332
332
  }
333
+ /* #224: the strip scrolls itself within a cap. A system row opened into its artboards (65 for a big system)
334
+ used to grow it past the panel: `.sh-sidebar` clips (F35), so the canvas list below — the panel's only
335
+ scroller — was squeezed to nothing and no wheel scrolled anything. Still `flex: none`: a shrinkable strip
336
+ gave way to the canvas list and cut the system row itself (26 of its 61 px). */
333
337
  .lp-pinned {
334
338
  flex: none;
339
+ max-height: 40%;
340
+ overflow-x: hidden;
341
+ overflow-y: auto;
342
+ overscroll-behavior: contain;
335
343
  margin: 0 var(--space-2) var(--space-1);
336
344
  padding-bottom: var(--space-1);
337
345
  box-shadow: inset 0 -0.5px 0 var(--border-default);