@1agh/maude 2.1.2 → 2.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.
@@ -32,10 +32,11 @@ import { THEME_WORD, ThemeIcon } from './canvas-theme-icons.tsx';
32
32
 
33
33
  /** The pill's chrome. Kept in step with the `.ds-bar` block of ds/board/board.css (same pill, other canvases). */
34
34
  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}
35
+ .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}
36
+ .dc-theme-pill-row{display:flex;align-items:center;gap:8px;min-width:0;max-width:100%;padding-left:4px}
37
+ .dc-theme-pill-row>:not(.dc-theme-pill-text){flex:none}
37
38
  .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}
39
+ .dc-theme-pill-text{display:flex;align-items:center;min-width:0;flex:0 1 auto}
39
40
  .dc-theme-pill-title{display:block;max-width:100%;overflow:hidden;text-overflow:ellipsis;font-weight:600;line-height:16px}
40
41
  .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
42
  .dc-theme-pill-seg:first-child{margin-left:0}
@@ -44,7 +45,7 @@ const PILL_CSS = `
44
45
  .dc-theme-pill-b:disabled{opacity:.4;cursor:default}
45
46
  .dc-theme-pill-b--ic{display:grid;place-items:center;padding:4px 7px}
46
47
  .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}
48
+ .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
49
  .dc-theme-pill[data-path="hidden"] .dc-theme-pill-path{position:absolute;visibility:hidden;pointer-events:none}
49
50
  .dc-theme-pill-path:hover{background:var(--maude-chrome-bg-3);color:var(--maude-chrome-fg-0)}
50
51
  .dc-theme-pill-path:focus-visible{outline:2px solid var(--maude-hud-focus-ring);outline-offset:1px}
@@ -215,10 +216,10 @@ export function CanvasThemePill({
215
216
  const pill = pillRef.current;
216
217
  if (!pill) return undefined;
217
218
  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;
219
+ // the path has its own line under the controls (Michal, #217): it may take the pill's whole inner width
220
+ const cs = getComputedStyle(pill);
221
+ const avail =
222
+ place.maxWidth - (parseFloat(cs.paddingLeft) || 0) - (parseFloat(cs.paddingRight) || 0);
222
223
  const btn = pathRef.current;
223
224
  let pathW = btn?.scrollWidth ?? 0;
224
225
  let chars = PATH_MAX;
@@ -231,7 +232,7 @@ export function CanvasThemePill({
231
232
  pathW = charW * shortenCanvasPath(file).length + pad;
232
233
  chars = Math.max(8, Math.min(PATH_MAX, Math.floor((avail - pad) / charW)));
233
234
  }
234
- const next = showPathLine(avail, titleRef.current?.scrollWidth ?? 0, pathW);
235
+ const next = showPathLine(avail, 0, pathW);
235
236
  setPathShown((cur) => (cur === next ? cur : next));
236
237
  setPathChars((cur) => (cur === chars ? cur : chars));
237
238
  };
@@ -255,63 +256,63 @@ export function CanvasThemePill({
255
256
  role="toolbar"
256
257
  aria-label="Canvas theme"
257
258
  >
258
- {name ? (
259
- <span className="dc-theme-pill-ic" aria-hidden="true">
260
- <DsIcon name="system" size={14} />
261
- </span>
259
+ {file ? (
260
+ <button
261
+ ref={pathRef}
262
+ type="button"
263
+ className="dc-theme-pill-path"
264
+ data-testid="canvas-theme-path"
265
+ title={`Copy relative path — ${file}`}
266
+ aria-label={`Copy relative path ${file}`}
267
+ aria-live="polite"
268
+ onClick={copyPath}
269
+ >
270
+ {copied === 'ok'
271
+ ? 'Copied'
272
+ : copied === 'failed'
273
+ ? 'Couldn’t copy'
274
+ : shortenCanvasPath(file, pathChars)}
275
+ </button>
262
276
  ) : null}
263
- {name || file ? (
264
- <span ref={textRef} className="dc-theme-pill-text" data-testid="canvas-theme-text">
265
- {name ? (
277
+ <div className="dc-theme-pill-row" data-testid="canvas-theme-row">
278
+ {name ? (
279
+ <span className="dc-theme-pill-ic" aria-hidden="true">
280
+ <DsIcon name="system" size={14} />
281
+ </span>
282
+ ) : null}
283
+ {name ? (
284
+ <span ref={textRef} className="dc-theme-pill-text" data-testid="canvas-theme-text">
266
285
  <b ref={titleRef} className="dc-theme-pill-title" data-testid="canvas-theme-title">
267
286
  {name}
268
287
  </b>
269
- ) : null}
270
- {file ? (
288
+ </span>
289
+ ) : null}
290
+ <fieldset className="dc-theme-pill-seg" aria-label="Show every artboard in">
291
+ {(['light', 'dark'] as const).map((m) => (
271
292
  <button
272
- ref={pathRef}
293
+ key={m}
273
294
  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}
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)}
280
303
  >
281
- {copied === 'ok'
282
- ? 'Copied'
283
- : copied === 'failed'
284
- ? 'Couldn’t copy'
285
- : shortenCanvasPath(file, pathChars)}
304
+ <ThemeIcon mode={m} />
286
305
  </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}
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}
315
+ </div>
315
316
  </div>
316
317
  </>
317
318
  );