@widgetic/canvas 0.5.39 → 0.5.40

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.
@@ -29,7 +29,7 @@
29
29
  import { CanvasHost, DEFAULT_HOST_PROPS } from './host/CanvasHost.js';
30
30
  import type { CanvasHostProps, SelectorGuide } from './host/CanvasHost.js';
31
31
  import { forwardToHost } from './host/CanvasHostApi.js';
32
- import { chromeSlots, panelClearanceFor, zoomVisibilityClasses } from './chromeLayout.js';
32
+ import { chromeSlots, panelClearanceFor, zoomVisibilityMinWidth } from './chromeLayout.js';
33
33
  import { DEFAULT_PAN_ZOOM_POSITION, normalizePanZoomPosition } from './panZoomPosition.js';
34
34
  import type { PanZoomPosition } from './panZoomPosition.js';
35
35
  import { DEFAULT_TOOLBAR_POSITION, normalizeToolbarPosition } from './toolbarPosition.js';
@@ -320,7 +320,7 @@
320
320
  $: toolbarAnchor = normalizeToolbarPosition(toolbarPosition);
321
321
  $: zoomAnchor = normalizePanZoomPosition(panZoomPosition);
322
322
  $: slots = chromeSlots(toolbarAnchor, zoomAnchor, { toolbar: showDrawingTools || showSelectorBar, zoom: showZoomControl });
323
- $: zoomVisibleFrom = zoomVisibilityClasses(toolbarAnchor, zoomAnchor);
323
+ $: zoomVisibleMinWidth = zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor);
324
324
  // The selection panel stands in the top corner at the end of the line: it keeps clear of the cards the page put there.
325
325
  $: panelClearance = panelClearanceFor(slots);
326
326
 
@@ -432,7 +432,7 @@
432
432
  <SelectorBar active={elementSelectorActive} guide={selectorGuide} anchor={toolbarAnchor} onToggle={() => onToggleElementSelector?.()} />
433
433
  {/if}
434
434
  {:else}
435
- <ZoomControl {host} state={engineState} ui={uiState} anchor={zoomAnchor} visibleFrom={zoomVisibleFrom} showZoom={showZoomPanel} {showSaveButton} />
435
+ <ZoomControl {host} state={engineState} ui={uiState} anchor={zoomAnchor} visibleMinWidth={zoomVisibleMinWidth} showZoom={showZoomPanel} {showSaveButton} />
436
436
  {/if}
437
437
  {/each}
438
438
  </div>
@@ -61,6 +61,8 @@ export declare function chromeSlots(toolbarAnchor: ChromeAnchor, zoomAnchor: Chr
61
61
  * behind them are in `ZOOM_CONTROL_MIN_WIDTHS`.
62
62
  */
63
63
  export declare function zoomVisibilityClasses(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor): string;
64
+ /** Minimum board width (px) before the zoom card is drawn; pairs with scoped `@container` CSS in `ZoomControl.svelte`. */
65
+ export declare function zoomVisibilityMinWidth(toolbarAnchor: ChromeAnchor, zoomAnchor: ChromeAnchor): number;
64
66
  /** What the selection panel (top right, 336 px wide) has to keep clear of. */
65
67
  export interface PanelClearance {
66
68
  /** A card stands on the top edge: the panel starts below it. */
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * Kept free of Svelte and of the DOM so that Node can test it.
19
19
  */
20
- import { ZOOM_CONTROL_VISIBLE_FROM } from './ui/floatingCard.js';
20
+ import { ZOOM_CONTROL_MIN_WIDTHS, ZOOM_CONTROL_VISIBLE_FROM } from './ui/floatingCard.js';
21
21
  /** The eight places a card can stand. */
22
22
  export const CHROME_ANCHORS = ['TL', 'TC', 'TR', 'CL', 'CR', 'BL', 'BC', 'BR'];
23
23
  /**
@@ -111,6 +111,19 @@ export function zoomVisibilityClasses(toolbarAnchor, zoomAnchor) {
111
111
  return ZOOM_CONTROL_VISIBLE_FROM.centredBesideCornerToolbar;
112
112
  return ZOOM_CONTROL_VISIBLE_FROM.oppositeCorners;
113
113
  }
114
+ /** Minimum board width (px) before the zoom card is drawn; pairs with scoped `@container` CSS in `ZoomControl.svelte`. */
115
+ export function zoomVisibilityMinWidth(toolbarAnchor, zoomAnchor) {
116
+ const className = zoomVisibilityClasses(toolbarAnchor, zoomAnchor);
117
+ if (className === ZOOM_CONTROL_VISIBLE_FROM.alone)
118
+ return ZOOM_CONTROL_MIN_WIDTHS.alone;
119
+ if (className === ZOOM_CONTROL_VISIBLE_FROM.sameSlot)
120
+ return ZOOM_CONTROL_MIN_WIDTHS.sameSlot;
121
+ if (className === ZOOM_CONTROL_VISIBLE_FROM.besideCentredToolbar)
122
+ return ZOOM_CONTROL_MIN_WIDTHS.besideCentredToolbar;
123
+ if (className === ZOOM_CONTROL_VISIBLE_FROM.centredBesideCornerToolbar)
124
+ return ZOOM_CONTROL_MIN_WIDTHS.centredBesideCornerToolbar;
125
+ return ZOOM_CONTROL_MIN_WIDTHS.oppositeCorners;
126
+ }
114
127
  const TOP_PANEL_CONFLICT_ANCHORS = new Set(['TC', 'TR']);
115
128
  /** What the panel keeps clear of, for the slots that are drawn. */
116
129
  export function panelClearanceFor(slots) {
@@ -699,7 +699,7 @@ export class CanvasHost {
699
699
  this.controller.pointerCancel({ pointerId: pending.pointerId });
700
700
  this.controller.prepareContextMenu({ x: pending.x, y: pending.y });
701
701
  this.#menuFinger = { pointerId: pending.pointerId, liftedAt: null };
702
- this.#updateUi({ contextMenu: { x: pending.x, y: pending.y, byTouch: true }, shapesMenuOpen: false });
702
+ this.#updateUi({ contextMenu: { x: pending.x, y: pending.y, byTouch: true }, shapesMenuOpen: false, selectionPanelDismissed: true });
703
703
  }
704
704
  /**
705
705
  * Is the menu still held by the finger that opened it? True while that finger is down, and for a moment after it lifts:
@@ -794,7 +794,7 @@ export class CanvasHost {
794
794
  this.focusBoard({ focusVisible: false });
795
795
  this.#menuFinger = null;
796
796
  this.controller.prepareContextMenu({ x: input.x, y: input.y });
797
- this.#updateUi({ contextMenu: { x: input.x, y: input.y }, shapesMenuOpen: false });
797
+ this.#updateUi({ contextMenu: { x: input.x, y: input.y }, shapesMenuOpen: false, selectionPanelDismissed: true });
798
798
  }
799
799
  /** A picture is being dragged over the board: say that it can be dropped. */
800
800
  handleDragOver(event) {
@@ -1029,6 +1029,18 @@ export class CanvasHost {
1029
1029
  last.hoverWidgetId !== state.hoverWidgetId ||
1030
1030
  last.selectedIds !== state.selectedIds ||
1031
1031
  last.overlayDragActive !== state.overlayDragActive) {
1032
+ if (last && last.selectedIds !== state.selectedIds) {
1033
+ if (state.selectedIds.length === 0) {
1034
+ // Leave dismissal as the user left it.
1035
+ }
1036
+ else {
1037
+ const selected = state.selectedIds
1038
+ .map((id) => state.scene.find((object) => object.id === id))
1039
+ .filter((object) => object !== undefined);
1040
+ const widgetOnly = selected.length === 1 && selected[0].type === 'widget';
1041
+ this.#updateUi({ selectionPanelDismissed: widgetOnly });
1042
+ }
1043
+ }
1032
1044
  this.#lastOverlayState = {
1033
1045
  scene: state.scene,
1034
1046
  viewport: state.viewport,
@@ -2,8 +2,8 @@
2
2
  Figma "Canvas Menu" and its "Layer order" submenu: the menu a right click (or a long press) opens on the board.
3
3
 
4
4
  Cut, Copy, Paste and Duplicate; Group and Ungroup; Layer order (a submenu of four) and Select all; Delete in the colour of a
5
- destructive action. Each row names the key that does the same, written for this platform (the symbols of a Mac, "Ctrl+" on
6
- the others). A row that cannot act on what is selected is dimmed.
5
+ destructive action. No leading icons; sentence-case labels; shortcuts as words ("Cmd X", "Shift Cmd G" on a Mac). A row that
6
+ cannot act on what is selected is dimmed. Opening the menu dismisses the selection panel (Figma shows no panel behind it).
7
7
 
8
8
  The menu is the design system's Dropdown Menu, anchored to the point of the board that was pressed, and drawn into the
9
9
  canvas's floating layer. The host decides when it opens (`ui.contextMenu`): a press on an object selects it first.
@@ -15,12 +15,10 @@
15
15
  import { useCanvasLanguage } from '../../i18n/language.js';
16
16
  import type { CanvasMessageKey } from '../../i18n/messages.js';
17
17
  import type { CanvasHost, HostUiState } from '../host/CanvasHost.js';
18
- import { ariaKeyShortcut, chordText, isApplePlatform } from './keyHints.js';
18
+ import { ariaKeyShortcut, isApplePlatform, menuChordText } from './keyHints.js';
19
19
  import type { Chord } from './keyHints.js';
20
- import type { CanvasIcon } from './icons.js';
21
- import { CANVAS_OVERLAY_Z_CLASS, MENU_PADDING_CLASS, OVERLAY_REDUCED_MOTION_CLASSES } from './floatingCard.js';
20
+ import { CANVAS_OVERLAY_Z_CLASS, LAYER_MENU_PADDING_CLASS, MENU_PADDING_CLASS, OVERLAY_REDUCED_MOTION_CLASSES } from './floatingCard.js';
22
21
  import { canvasOverlayPortalProps, useFloatingLayer } from './floatingLayer.js';
23
- import { IconArrowBarToDown, IconArrowBarToUp, IconClipboard, IconCopy, IconReplace, IconScissors, IconSelectAll, IconStack, IconStack2, IconStackBack, IconStackFront, IconStackPop, IconTrash } from './icons.js';
24
22
 
25
23
  interface Props {
26
24
  host: CanvasHost;
@@ -38,10 +36,9 @@
38
36
  const { t } = useCanvasLanguage();
39
37
  const apple = isApplePlatform();
40
38
 
41
- /** A row of the menu: what it is called, its icon, the keys, whether it can act, and what it does. */
39
+ /** A row of the menu: what it is called, the keys, whether it can act, and what it does. */
42
40
  interface Row {
43
41
  label: CanvasMessageKey;
44
- icon: CanvasIcon;
45
42
  chord?: Chord;
46
43
  disabled: boolean;
47
44
  run: () => void;
@@ -60,22 +57,22 @@
60
57
  const point = $derived(ui.contextMenu);
61
58
 
62
59
  const clipboardRows = $derived<Row[]>([
63
- { label: 'canvas.action.cut', icon: IconScissors, chord: { mod: true, key: 'X' }, disabled: !hasSelection, run: () => void host.cutSelection() },
64
- { label: 'canvas.action.copy', icon: IconCopy, chord: { mod: true, key: 'C' }, disabled: !hasSelection, run: () => void host.copySelection() },
65
- { label: 'canvas.action.paste', icon: IconClipboard, chord: { mod: true, key: 'V' }, disabled: false, run: () => void host.pasteAt(point) },
66
- { label: 'canvas.action.duplicate', icon: IconReplace, chord: { mod: true, key: 'D' }, disabled: !hasSelection, run: () => void host.duplicateSelectedObjects() }
60
+ { label: 'canvas.action.cut', chord: { mod: true, key: 'X' }, disabled: !hasSelection, run: () => void host.cutSelection() },
61
+ { label: 'canvas.action.copy', chord: { mod: true, key: 'C' }, disabled: !hasSelection, run: () => void host.copySelection() },
62
+ { label: 'canvas.action.paste', chord: { mod: true, key: 'V' }, disabled: false, run: () => void host.pasteAt(point) },
63
+ { label: 'canvas.action.duplicate', chord: { mod: true, key: 'D' }, disabled: !hasSelection, run: () => void host.duplicateSelectedObjects() }
67
64
  ]);
68
65
 
69
66
  const groupRows = $derived<Row[]>([
70
- { label: 'canvas.action.group', icon: IconStack2, chord: { mod: true, key: 'G' }, disabled: !canGroup, run: () => void host.onGroupSelection() },
71
- { label: 'canvas.action.ungroup', icon: IconStackPop, chord: { mod: true, shift: true, key: 'G' }, disabled: !canUngroup, run: () => host.onUngroupSelection() }
67
+ { label: 'canvas.action.group', chord: { mod: true, key: 'G' }, disabled: !canGroup, run: () => void host.onGroupSelection() },
68
+ { label: 'canvas.action.ungroup', chord: { mod: true, shift: true, key: 'G' }, disabled: !canUngroup, run: () => host.onUngroupSelection() }
72
69
  ]);
73
70
 
74
71
  const layerRows = $derived<(Row & { mode: ReorderMode })[]>([
75
- { mode: 'front', label: 'canvas.layer.front', icon: IconArrowBarToUp, chord: { mod: true, shift: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('front') },
76
- { mode: 'forward', label: 'canvas.layer.forward', icon: IconStackFront, chord: { mod: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('forward') },
77
- { mode: 'backward', label: 'canvas.layer.backward', icon: IconStackBack, chord: { mod: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('backward') },
78
- { mode: 'back', label: 'canvas.layer.back', icon: IconArrowBarToDown, chord: { mod: true, shift: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('back') }
72
+ { mode: 'front', label: 'canvas.layer.front', chord: { mod: true, shift: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('front') },
73
+ { mode: 'forward', label: 'canvas.layer.forward', chord: { mod: true, key: ']' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('forward') },
74
+ { mode: 'backward', label: 'canvas.layer.backward', chord: { mod: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('backward') },
75
+ { mode: 'back', label: 'canvas.layer.back', chord: { mod: true, shift: true, key: '[' }, disabled: !hasSelection, run: () => void host.engine.reorderSelection('back') }
79
76
  ]);
80
77
 
81
78
  /** Where the menu opens on the page: the pressed point of the board, which is only known once the board is. */
@@ -116,11 +113,30 @@
116
113
 
117
114
  <!-- The keys are written beside the name for the eye (hidden from the name a screen reader reads) and given as `aria-keyshortcuts`. -->
118
115
  {#snippet rowView(row: Row)}
119
- <DropdownMenu.Item disabled={row.disabled} aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined} onSelect={(event) => choose(event, row.run)}>
120
- <row.icon />
121
- <span class="flex-1">{$t(row.label)}</span>
116
+ <DropdownMenu.Item
117
+ class="h-8 min-h-8 gap-2 px-2 py-1.5"
118
+ disabled={row.disabled}
119
+ aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined}
120
+ onSelect={(event) => choose(event, row.run)}
121
+ >
122
+ <span class="flex-1 text-body">{$t(row.label)}</span>
122
123
  {#if row.chord}
123
- <DropdownMenu.Shortcut aria-hidden="true">{chordText(row.chord, apple, $t)}</DropdownMenu.Shortcut>
124
+ <DropdownMenu.Shortcut aria-hidden="true">{menuChordText(row.chord, apple, $t)}</DropdownMenu.Shortcut>
125
+ {/if}
126
+ </DropdownMenu.Item>
127
+ {/snippet}
128
+
129
+ <!-- Figma layer submenu rows (519:477): label + shortcut only, 32 px tall, no leading icon. -->
130
+ {#snippet layerMenuRowView(row: Row)}
131
+ <DropdownMenu.Item
132
+ class="h-8 min-h-8 gap-2 px-2 py-1.5 [&_svg]:hidden"
133
+ disabled={row.disabled}
134
+ aria-keyshortcuts={row.chord ? ariaKeyShortcut(row.chord, apple) : undefined}
135
+ onSelect={(event) => choose(event, row.run)}
136
+ >
137
+ <span class="flex-1 text-body">{$t(row.label)}</span>
138
+ {#if row.chord}
139
+ <DropdownMenu.Shortcut class="text-caption text-muted-foreground" aria-hidden="true">{menuChordText(row.chord, apple, $t)}</DropdownMenu.Shortcut>
124
140
  {/if}
125
141
  </DropdownMenu.Item>
126
142
  {/snippet}
@@ -136,37 +152,51 @@
136
152
  onCloseAutoFocus={returnFocusToBoard}
137
153
  aria-label={$t('canvas.panel.actions')}
138
154
  data-canvas-context-menu
139
- class="{CANVAS_OVERLAY_Z_CLASS} w-[240px] {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}"
155
+ class="{CANVAS_OVERLAY_Z_CLASS} w-[240px] py-1 {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}"
140
156
  >
141
157
  {#each clipboardRows as row (row.label)}
142
158
  {@render rowView(row)}
143
159
  {/each}
144
- <DropdownMenu.Separator />
160
+ <DropdownMenu.Separator class="my-0 h-px min-h-px" />
145
161
  {#each groupRows as row (row.label)}
146
162
  {@render rowView(row)}
147
163
  {/each}
148
- <DropdownMenu.Separator />
164
+ <DropdownMenu.Separator class="my-0 h-px min-h-px" />
149
165
  <DropdownMenu.Sub>
150
- <DropdownMenu.SubTrigger disabled={!hasSelection}>
151
- <IconStack />
152
- <span class="flex-1">{$t('canvas.layer.title')}</span>
166
+ <DropdownMenu.SubTrigger class="h-8 min-h-8 gap-2 px-2 py-1.5" disabled={!hasSelection}>
167
+ <span class="flex-1 text-body">{$t('canvas.layer.title')}</span>
153
168
  </DropdownMenu.SubTrigger>
154
- <DropdownMenu.SubContent aria-label={$t('canvas.layer.title')} class="{CANVAS_OVERLAY_Z_CLASS} w-[220px] {MENU_PADDING_CLASS} shadow-floating {OVERLAY_REDUCED_MOTION_CLASSES}">
169
+ <DropdownMenu.SubContent
170
+ align="start"
171
+ alignOffset={12}
172
+ sideOffset={13}
173
+ aria-label={$t('canvas.layer.title')}
174
+ data-canvas-layer-menu
175
+ class="{CANVAS_OVERLAY_Z_CLASS} w-[220px] rounded-xl border border-border bg-popover {LAYER_MENU_PADDING_CLASS} shadow-floating {OVERLAY_REDUCED_MOTION_CLASSES}"
176
+ >
155
177
  {#each layerRows as row (row.mode)}
156
- {@render rowView(row)}
178
+ {@render layerMenuRowView(row)}
157
179
  {/each}
158
180
  </DropdownMenu.SubContent>
159
181
  </DropdownMenu.Sub>
160
- <DropdownMenu.Item disabled={boardIsEmpty} aria-keyshortcuts={ariaKeyShortcut({ mod: true, key: 'A' }, apple)} onSelect={(event) => choose(event, () => host.onSelectAllObjects())}>
161
- <IconSelectAll />
162
- <span class="flex-1">{$t('canvas.action.selectAll')}</span>
163
- <DropdownMenu.Shortcut aria-hidden="true">{chordText({ mod: true, key: 'A' }, apple, $t)}</DropdownMenu.Shortcut>
182
+ <DropdownMenu.Item
183
+ class="h-8 min-h-8 gap-2 px-2 py-1.5"
184
+ disabled={boardIsEmpty}
185
+ aria-keyshortcuts={ariaKeyShortcut({ mod: true, key: 'A' }, apple)}
186
+ onSelect={(event) => choose(event, () => host.onSelectAllObjects())}
187
+ >
188
+ <span class="flex-1 text-body">{$t('canvas.action.selectAll')}</span>
189
+ <DropdownMenu.Shortcut aria-hidden="true">{menuChordText({ mod: true, key: 'A' }, apple, $t)}</DropdownMenu.Shortcut>
164
190
  </DropdownMenu.Item>
165
- <DropdownMenu.Separator />
166
- <DropdownMenu.Item data-variant="destructive" disabled={!hasSelection} aria-keyshortcuts="Delete" onSelect={(event) => choose(event, () => void host.deleteSelectedObjects())}>
167
- <IconTrash />
168
- <span class="flex-1">{$t('canvas.action.delete')}</span>
169
- <DropdownMenu.Shortcut aria-hidden="true">{$t('canvas.key.delete')}</DropdownMenu.Shortcut>
191
+ <DropdownMenu.Separator class="my-0 h-px min-h-px" />
192
+ <DropdownMenu.Item
193
+ class="h-8 min-h-8 gap-2 px-2 py-1.5"
194
+ data-variant="destructive"
195
+ disabled={!hasSelection}
196
+ aria-keyshortcuts="Delete"
197
+ onSelect={(event) => choose(event, () => void host.deleteSelectedObjects())}
198
+ >
199
+ <span class="flex-1 text-body">{$t('canvas.action.delete')}</span>
170
200
  </DropdownMenu.Item>
171
201
  </DropdownMenu.Content>
172
202
  {/if}
@@ -10,8 +10,8 @@
10
10
  const { t } = useCanvasLanguage();
11
11
  </script>
12
12
 
13
- <div class="pointer-events-none absolute inset-0 flex items-center justify-center p-6" data-canvas-hint>
14
- <div class="flex w-80 max-w-full flex-col items-center gap-3 text-center">
13
+ <div class="pointer-events-none absolute inset-x-0 top-0 flex justify-center pt-[312px] max-md:inset-0 max-md:items-center max-md:pt-0 max-md:p-6" data-canvas-hint>
14
+ <div class="flex w-80 max-w-full flex-col items-center gap-2.5 text-center">
15
15
  <div class="flex size-9 items-center justify-center rounded-lg border border-border bg-background text-foreground">
16
16
  <IconPencil class="size-4 stroke-[1.333]" aria-hidden="true" />
17
17
  </div>
@@ -22,7 +22,7 @@
22
22
  import { isSideAnchor, popoverSideFor } from '../chromeLayout.js';
23
23
  import type { ChromeAnchor } from '../chromeLayout.js';
24
24
  import type { CanvasHost, HostUiState } from '../host/CanvasHost.js';
25
- import { FLOATING_CARD_CLASSES, TOOLBAR_HISTORY_VISIBLE_FROM } from './floatingCard.js';
25
+ import { FLOATING_CARD_CLASSES, TOOLBAR_ICON_STROKE_CLASSES } from './floatingCard.js';
26
26
  import { providePopoverSide } from './popoverSide.js';
27
27
  import ShapesMenu from './ShapesMenu.svelte';
28
28
  import ToolButton from './ToolButton.svelte';
@@ -52,7 +52,7 @@
52
52
  aria-label={$t('canvas.toolbar.label')}
53
53
  data-canvas-toolbar
54
54
  data-anchor={anchor}
55
- class="canvas-toolbar-el pointer-events-auto flex items-center gap-1 {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full'} {FLOATING_CARD_CLASSES}"
55
+ class="canvas-toolbar-el pointer-events-auto flex items-center gap-1 {vertical ? 'max-h-full flex-col overflow-y-auto' : 'max-w-full'} {FLOATING_CARD_CLASSES} {TOOLBAR_ICON_STROKE_CLASSES} [&_svg]:size-4"
56
56
  data-canvas-ui
57
57
  >
58
58
  {#if showDrawingTools}
@@ -84,7 +84,9 @@
84
84
  />
85
85
 
86
86
  <!-- The history group is the first thing a board too narrow for the whole bar gives up (Figma's phone): undo and redo stay on the keys. An upright bar is as long as the board is tall, so it keeps them. -->
87
- <div class="items-center gap-1 {vertical ? 'flex flex-col' : TOOLBAR_HISTORY_VISIBLE_FROM}">
87
+ <div
88
+ class="canvas-toolbar-history items-center gap-1 {vertical ? 'flex flex-col is-upright' : ''}"
89
+ >
88
90
  <Separator orientation={vertical ? 'horizontal' : 'vertical'} class={vertical ? 'w-5' : 'h-5 min-h-0'} />
89
91
  <ToolButton label={$t('canvas.tool.undo')} disabled={!state.canUndo} onclick={() => void host.undo()}>
90
92
  <IconArrowBackUp class="rtl:-scale-x-100" />
@@ -94,3 +96,18 @@
94
96
  </ToolButton>
95
97
  </div>
96
98
  </div>
99
+
100
+ <style>
101
+ /* Tailwind container variants from `floatingCard.ts` are not emitted in the site dev bundle; keep Figma's 384px cutoff on the board container. */
102
+ .canvas-toolbar-history {
103
+ display: none;
104
+ }
105
+ .canvas-toolbar-history.is-upright {
106
+ display: flex;
107
+ }
108
+ @container (min-width: 384px) {
109
+ .canvas-toolbar-history:not(.is-upright) {
110
+ display: flex;
111
+ }
112
+ }
113
+ </style>
@@ -104,7 +104,7 @@
104
104
  data-canvas-color-picker-trigger
105
105
  aria-label="{label}: {fieldText}"
106
106
  title={$t('canvas.panel.pickColor')}
107
- class="flex h-9 w-[185px] items-center justify-between gap-2 rounded-lg bg-accent px-3 text-body text-foreground transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring"
107
+ class="flex h-9 w-[185px] min-h-9 items-center justify-between gap-2 rounded-lg bg-accent py-0 ps-3 pe-2 text-body text-foreground transition-colors duration-fast focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring data-[state=open]:ring-2 data-[state=open]:ring-ring"
108
108
  >
109
109
  <span class="truncate tabular-nums">{fieldText}</span>
110
110
  <span class="size-5 shrink-0 rounded-md border border-border" style:background={swatchBackground}></span>
@@ -38,6 +38,7 @@
38
38
  import { describeSelection, formatFontSizeDisplay, showFillColorRow, showStrokeColorRow, traitNumber } from './selectionTraits.js';
39
39
  import ToolButton from './ToolButton.svelte';
40
40
  import WidgetActions from './WidgetActions.svelte';
41
+ import { shouldOfferSelectionPanelForTraits } from './widgetSelectionPanel.js';
41
42
 
42
43
  interface Props {
43
44
  host: CanvasHost;
@@ -151,7 +152,9 @@
151
152
  const strokeWidthValue = $derived(traitNumber(traits.strokeWidth, 0));
152
153
  const fontSizeValue = $derived(traits.text ? traitNumber(traits.text.fontSize, 16) : 16);
153
154
 
154
- const showPanel = $derived(hasSelection || (canCapture && !canConvert));
155
+ const showPanel = $derived(
156
+ (shouldOfferSelectionPanelForTraits(traits) && hasSelection) || (canCapture && !canConvert),
157
+ );
155
158
  const showFillColor = $derived(showFillColorRow(traits, wireframeMode));
156
159
  const showStrokeColor = $derived(showStrokeColorRow(traits, wireframeMode));
157
160
  const fontSizeDisplay = $derived(traits.text ? formatFontSizeDisplay(traits.text.fontSize) : '–');
@@ -178,11 +181,12 @@
178
181
  aria-label={$t('canvas.panel.label')}
179
182
  data-canvas-ui
180
183
  data-canvas-selection-panel
181
- class="pointer-events-auto absolute end-4 z-20 flex w-[336px] flex-col gap-3 overflow-y-auto rounded-card border border-border bg-popover p-4 text-foreground shadow-floating {clearance.belowTopCards ? 'top-16 max-h-[calc(100%-5rem)]' : 'top-4 max-h-[calc(100%-2rem)]'} {PANEL_MAX_WIDTH_CLASSES[clearance.besideSideCard ?? 'none']}"
184
+ class="pointer-events-auto absolute end-4 z-20 flex min-h-[304px] w-[336px] flex-col gap-4 overflow-y-auto rounded-card border border-border bg-popover p-4 text-foreground shadow-floating {clearance.belowTopCards ? 'top-16 max-h-[calc(100%-5rem)]' : 'top-4 max-h-[calc(100%-2rem)]'} {PANEL_MAX_WIDTH_CLASSES[clearance.besideSideCard ?? 'none']}"
182
185
  style:inset-inline-end={clearance.besideSideCard ? PANEL_END_BESIDE_SIDE_CARD[clearance.besideSideCard] : undefined}
183
186
  >
184
- <header class="flex items-center justify-between gap-2">
185
- <h2 class="truncate text-body font-semibold">{title}</h2>
187
+ <header class="flex h-8 w-full shrink-0 items-center gap-2">
188
+ <h2 class="truncate text-body font-semibold leading-5">{title}</h2>
189
+ <div class="min-h-px min-w-0 flex-1" aria-hidden="true"></div>
186
190
  {#if hasSelection}
187
191
  <IconButton label={$t('canvas.panel.close')} onclick={dismiss}>
188
192
  <IconX />
@@ -191,22 +195,22 @@
191
195
  </header>
192
196
 
193
197
  {#if showFillColor}
194
- <div class="flex h-9 items-center justify-between gap-3">
195
- <span class="text-body">{$t('canvas.panel.fill')}</span>
198
+ <div class="flex h-9 w-full items-start" data-canvas-panel-row="fill">
199
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.fill')}</span>
196
200
  <ColorField label={$t('canvas.panel.fill')} value={traits.fill} allowNone={!traits.text} onchange={changeFill} />
197
201
  </div>
198
202
  {/if}
199
203
 
200
204
  {#if showStrokeColor}
201
- <div class="flex h-9 items-center justify-between gap-3">
202
- <span class="text-body">{$t('canvas.panel.stroke')}</span>
205
+ <div class="flex h-9 w-full items-start" data-canvas-panel-row="stroke">
206
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.stroke')}</span>
203
207
  <ColorField label={$t('canvas.panel.stroke')} value={traits.stroke} onchange={(color, commit) => changeStyle({ stroke: color }, commit)} />
204
208
  </div>
205
209
  {/if}
206
210
 
207
211
  {#if traits.strokeWidth.kind !== 'none'}
208
- <div class="flex h-9 items-center justify-between gap-3">
209
- <span class="text-body">{$t('canvas.panel.strokeWidth')}</span>
212
+ <div class="flex h-9 w-full items-start" data-canvas-panel-row="strokeWidth">
213
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.strokeWidth')}</span>
210
214
  <!-- The design system's number stepper (IC Number): the value can be typed or stepped, and the group names the two buttons after the row. -->
211
215
  <NumberStepper
212
216
  class="w-[185px]"
@@ -224,9 +228,9 @@
224
228
  {/if}
225
229
 
226
230
  {#if traits.roundness.kind !== 'none'}
227
- <div class="flex h-9 items-center justify-between gap-3" role="group" aria-label={$t('canvas.panel.roundness')} {@attach nameSliderThumb($t('canvas.panel.roundness'))}>
228
- <span class="text-body">{$t('canvas.panel.roundness')}</span>
229
- <div class="flex w-[185px] items-center gap-3">
231
+ <div class="flex h-9 w-full items-start" data-canvas-panel-row="roundness" role="group" aria-label={$t('canvas.panel.roundness')} {@attach nameSliderThumb($t('canvas.panel.roundness'))}>
232
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.roundness')}</span>
233
+ <div class="flex w-[185px] shrink-0 items-center gap-3">
230
234
  <Slider type="single" min={0} max={100} step={1} value={Math.round(traitNumber(traits.roundness, 0))} onValueChange={(next: number) => changeStyle({ roundness: next }, false)} onValueCommit={endChange} />
231
235
  <span class="w-7 shrink-0 text-end text-body tabular-nums">{traits.roundness.kind === 'same' ? traits.roundness.value : '–'}</span>
232
236
  </div>
@@ -234,9 +238,9 @@
234
238
  {/if}
235
239
 
236
240
  {#if traits.opacity.kind !== 'none'}
237
- <div class="flex h-9 items-center justify-between gap-3" role="group" aria-label={$t('canvas.panel.opacity')} {@attach nameSliderThumb($t('canvas.panel.opacity'))}>
238
- <span class="text-body">{$t('canvas.panel.opacity')}</span>
239
- <div class="flex w-[185px] items-center gap-3">
241
+ <div class="flex h-9 w-full items-start" data-canvas-panel-row="opacity" role="group" aria-label={$t('canvas.panel.opacity')} {@attach nameSliderThumb($t('canvas.panel.opacity'))}>
242
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.opacity')}</span>
243
+ <div class="flex w-[185px] shrink-0 items-center gap-3">
240
244
  <Slider type="single" min={0} max={100} step={1} value={percent(traitNumber(traits.opacity, 1))} onValueChange={(next: number) => changeStyle({ opacity: next / 100 }, false)} onValueCommit={endChange} />
241
245
  <span class="w-7 shrink-0 text-end text-body tabular-nums">{traits.opacity.kind === 'same' ? percent(traits.opacity.value) : '–'}</span>
242
246
  </div>
@@ -244,8 +248,8 @@
244
248
  {/if}
245
249
 
246
250
  {#if traits.text}
247
- <div class="flex h-9 items-center justify-between gap-3">
248
- <span class="text-body">{$t('canvas.control.fontFamily')}</span>
251
+ <div class="flex h-9 w-full items-start">
252
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.control.fontFamily')}</span>
249
253
  <Select.Root
250
254
  type="single"
251
255
  value={traits.text.fontFamily.kind === 'same' ? traits.text.fontFamily.value : undefined}
@@ -287,8 +291,8 @@
287
291
  </Select.Root>
288
292
  </div>
289
293
 
290
- <div class="flex h-9 items-center justify-between gap-3">
291
- <span class="text-body">{$t('canvas.panel.fontSize')}</span>
294
+ <div class="flex h-9 w-full items-start">
295
+ <span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.fontSize')}</span>
292
296
  <NumberStepper
293
297
  class="w-[185px]"
294
298
  label={$t('canvas.panel.fontSize')}
@@ -147,8 +147,6 @@
147
147
  <DropdownMenu.Item aria-keyshortcuts={imageShortcut} onSelect={() => void host.addImage()}>
148
148
  <IconPhoto />
149
149
  <span class="flex-1">{$t('canvas.tool.image')}</span>
150
- <!-- The key is for the eye: the name a screen reader reads is "Image", and the key is given as `aria-keyshortcuts`. -->
151
- <DropdownMenu.Shortcut aria-hidden="true">{imageShortcut}</DropdownMenu.Shortcut>
152
150
  </DropdownMenu.Item>
153
151
  <DropdownMenu.Item onSelect={() => void host.addSvg()}>
154
152
  <IconBrowser />
@@ -68,7 +68,7 @@
68
68
  }
69
69
  </script>
70
70
 
71
- {#if canCapture && !(canConvert && hasSelection)}
71
+ {#if canCapture && !hasSelection}
72
72
  <div class="flex flex-col gap-2">
73
73
  <span class="text-caption-medium text-muted-foreground">{$t('canvas.widget.createPreview')}</span>
74
74
  <Button variant="outline" size="sm" onclick={() => void host.captureSelection()}>
@@ -33,14 +33,14 @@
33
33
  ui: HostUiState;
34
34
  /** Where the control stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
35
35
  anchor: ChromeAnchor;
36
- /** The classes that show the zoom card from the width of board it needs (see `zoomVisibilityClasses`). */
37
- visibleFrom: string;
36
+ /** Board width (px) from which the zoom card is drawn (`zoomVisibilityMinWidth` on the host canvas). */
37
+ visibleMinWidth: number;
38
38
  /** The page's `showZoomPanel`: whether the zoom card is drawn at all. */
39
39
  showZoom: boolean;
40
40
  showSaveButton: boolean;
41
41
  }
42
42
 
43
- let { host, state, ui, anchor, visibleFrom, showZoom, showSaveButton }: Props = $props();
43
+ let { host, state, ui, anchor, visibleMinWidth, showZoom, showSaveButton }: Props = $props();
44
44
 
45
45
  const { t } = useCanvasLanguage();
46
46
 
@@ -55,7 +55,12 @@
55
55
 
56
56
  <div class="pointer-events-auto flex gap-2 {vertical ? 'flex-col items-center' : 'items-center'}" data-canvas-zoom-control data-anchor={anchor}>
57
57
  {#if showZoom}
58
- <div role="group" aria-label={$t('canvas.zoom.groupLabel')} class="{visibleFrom} items-center gap-1 {vertical ? 'flex-col' : ''} {FLOATING_CARD_CLASSES}">
58
+ <div
59
+ role="group"
60
+ aria-label={$t('canvas.zoom.groupLabel')}
61
+ data-zoom-min-width={visibleMinWidth}
62
+ class="canvas-zoom-card items-center gap-1 {vertical ? 'flex-col is-upright' : ''} {FLOATING_CARD_CLASSES}"
63
+ >
59
64
  <ToolButton size="compact" label={$t('canvas.zoom.outLabel')} shortcut={chordText({ mod: true, key: '−' }, apple, $t)} onclick={() => host.zoomOut()}>
60
65
  <IconZoomOut />
61
66
  </ToolButton>
@@ -87,3 +92,33 @@
87
92
  </div>
88
93
  {/if}
89
94
  </div>
95
+
96
+ <style>
97
+ /* Tailwind `@lg` / `@[Npx]` container variants are not emitted in the site dev bundle; honour Figma widths on the board container. */
98
+ .canvas-zoom-card {
99
+ display: none;
100
+ }
101
+ .canvas-zoom-card.is-upright {
102
+ display: flex;
103
+ }
104
+ @container (min-width: 512px) {
105
+ .canvas-zoom-card[data-zoom-min-width='512']:not(.is-upright) {
106
+ display: flex;
107
+ }
108
+ }
109
+ @container (min-width: 560px) {
110
+ .canvas-zoom-card[data-zoom-min-width='560']:not(.is-upright) {
111
+ display: flex;
112
+ }
113
+ }
114
+ @container (min-width: 720px) {
115
+ .canvas-zoom-card[data-zoom-min-width='720']:not(.is-upright) {
116
+ display: flex;
117
+ }
118
+ }
119
+ @container (min-width: 912px) {
120
+ .canvas-zoom-card[data-zoom-min-width='912']:not(.is-upright) {
121
+ display: flex;
122
+ }
123
+ }
124
+ </style>
@@ -7,8 +7,8 @@ interface Props {
7
7
  ui: HostUiState;
8
8
  /** Where the control stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
9
9
  anchor: ChromeAnchor;
10
- /** The classes that show the zoom card from the width of board it needs (see `zoomVisibilityClasses`). */
11
- visibleFrom: string;
10
+ /** Board width (px) from which the zoom card is drawn (`zoomVisibilityMinWidth` on the host canvas). */
11
+ visibleMinWidth: number;
12
12
  /** The page's `showZoomPanel`: whether the zoom card is drawn at all. */
13
13
  showZoom: boolean;
14
14
  showSaveButton: boolean;
@@ -20,6 +20,8 @@ export declare const FLOATING_CARD_CLASSES = "rounded-xl border border-border bg
20
20
  * the Shape Menu is 196 x 246 there, and measures 246 only with 3 px.
21
21
  */
22
22
  export declare const MENU_PADDING_CLASS = "p-[3px]";
23
+ /** Figma "Layer Menu" (519:*): 4 px inset, 220 × 136 with 32 px rows. */
24
+ export declare const LAYER_MENU_PADDING_CLASS = "p-1";
23
25
  /**
24
26
  * A menu, a popover or a tooltip of the design system slides and fades in, and its classes do not ask whether the system wants
25
27
  * less motion. The canvas adds this to each one it draws: with `prefers-reduced-motion: reduce` the card appears and goes
@@ -74,7 +76,7 @@ export declare const FLOATING_CARD_METRICS: {
74
76
  * with. (An upright bar is as long as the board is tall, so it always has them.) Written out in full, so a page's stylesheet
75
77
  * picks it up.
76
78
  */
77
- export declare const TOOLBAR_HISTORY_VISIBLE_FROM = "hidden @min-[384px]:flex";
79
+ export declare const TOOLBAR_HISTORY_VISIBLE_FROM = "hidden @[384px]:flex";
78
80
  /**
79
81
  * The width of board from which the zoom card is drawn, by the way it stands beside the toolbar (see `chromeLayout.ts`, which
80
82
  * picks the case from the two anchors a page named). Narrower than that the zoom card is not drawn, as in Figma's phone: a
@@ -100,8 +102,8 @@ export declare const ZOOM_CONTROL_MIN_WIDTHS: {
100
102
  /** The classes that show the zoom card from each of those widths. Written out in full, so a page's stylesheet picks every one up. */
101
103
  export declare const ZOOM_CONTROL_VISIBLE_FROM: {
102
104
  readonly alone: "hidden @lg:flex";
103
- readonly sameSlot: "hidden @min-[560px]:flex";
104
- readonly oppositeCorners: "hidden @min-[560px]:flex";
105
- readonly besideCentredToolbar: "hidden @min-[720px]:flex";
106
- readonly centredBesideCornerToolbar: "hidden @min-[912px]:flex";
105
+ readonly sameSlot: "hidden @[560px]:flex";
106
+ readonly oppositeCorners: "hidden @[560px]:flex";
107
+ readonly besideCentredToolbar: "hidden @[720px]:flex";
108
+ readonly centredBesideCornerToolbar: "hidden @[912px]:flex";
107
109
  };
@@ -20,6 +20,8 @@ export const FLOATING_CARD_CLASSES = 'rounded-xl border border-border bg-backgro
20
20
  * the Shape Menu is 196 x 246 there, and measures 246 only with 3 px.
21
21
  */
22
22
  export const MENU_PADDING_CLASS = 'p-[3px]';
23
+ /** Figma "Layer Menu" (519:*): 4 px inset, 220 × 136 with 32 px rows. */
24
+ export const LAYER_MENU_PADDING_CLASS = 'p-1';
23
25
  /**
24
26
  * A menu, a popover or a tooltip of the design system slides and fades in, and its classes do not ask whether the system wants
25
27
  * less motion. The canvas adds this to each one it draws: with `prefers-reduced-motion: reduce` the card appears and goes
@@ -74,7 +76,7 @@ export const FLOATING_CARD_METRICS = {
74
76
  * with. (An upright bar is as long as the board is tall, so it always has them.) Written out in full, so a page's stylesheet
75
77
  * picks it up.
76
78
  */
77
- export const TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @min-[384px]:flex';
79
+ export const TOOLBAR_HISTORY_VISIBLE_FROM = 'hidden @[384px]:flex';
78
80
  /**
79
81
  * The width of board from which the zoom card is drawn, by the way it stands beside the toolbar (see `chromeLayout.ts`, which
80
82
  * picks the case from the two anchors a page named). Narrower than that the zoom card is not drawn, as in Figma's phone: a
@@ -100,8 +102,8 @@ export const ZOOM_CONTROL_MIN_WIDTHS = {
100
102
  /** The classes that show the zoom card from each of those widths. Written out in full, so a page's stylesheet picks every one up. */
101
103
  export const ZOOM_CONTROL_VISIBLE_FROM = {
102
104
  alone: 'hidden @lg:flex',
103
- sameSlot: 'hidden @min-[560px]:flex',
104
- oppositeCorners: 'hidden @min-[560px]:flex',
105
- besideCentredToolbar: 'hidden @min-[720px]:flex',
106
- centredBesideCornerToolbar: 'hidden @min-[912px]:flex'
105
+ sameSlot: 'hidden @[560px]:flex',
106
+ oppositeCorners: 'hidden @[560px]:flex',
107
+ besideCentredToolbar: 'hidden @[720px]:flex',
108
+ centredBesideCornerToolbar: 'hidden @[912px]:flex'
107
109
  };
@@ -24,4 +24,9 @@ export declare function ariaKeyShortcut(chord: Chord, apple: boolean): string |
24
24
  * the same in every language; the words of the others come from the page's language.
25
25
  */
26
26
  export declare function chordText(chord: Chord, apple: boolean, t: Translator): string;
27
+ /**
28
+ * Shortcut text beside a context-menu row, as in Figma: "Cmd X", "Shift Cmd G" on a Mac; "Ctrl X", "Ctrl Shift G"
29
+ * elsewhere. The toolbar and zoom control keep `chordText` (symbols on Apple).
30
+ */
31
+ export declare function menuChordText(chord: Chord, apple: boolean, t: Translator): string;
27
32
  export {};
@@ -41,3 +41,17 @@ export function chordText(chord, apple, t) {
41
41
  parts.push(key);
42
42
  return parts.join('+');
43
43
  }
44
+ /**
45
+ * Shortcut text beside a context-menu row, as in Figma: "Cmd X", "Shift Cmd G" on a Mac; "Ctrl X", "Ctrl Shift G"
46
+ * elsewhere. The toolbar and zoom control keep `chordText` (symbols on Apple).
47
+ */
48
+ export function menuChordText(chord, apple, t) {
49
+ const key = typeof chord.key === 'string' ? chord.key : t(chord.key.name);
50
+ const parts = [];
51
+ if (chord.shift)
52
+ parts.push(t('canvas.key.shift'));
53
+ if (chord.mod)
54
+ parts.push(apple ? 'Cmd' : t('canvas.key.ctrl'));
55
+ parts.push(key);
56
+ return parts.join(' ');
57
+ }
@@ -9,5 +9,8 @@ export interface SizeLabelVisibilityInput {
9
9
  /** Non-null only after the pointer crossed the drag threshold. */
10
10
  overlayDragging: SelectionDrag | null;
11
11
  }
12
- /** True while the selection is at rest, or between press and the drag threshold. */
12
+ /**
13
+ * True only while the selection is being resized (Figma "Selection Box" keeps the size chip hidden at rest;
14
+ * see 515:623 `hidden` on the component board).
15
+ */
13
16
  export declare function shouldShowRestingSizeLabel(input: SizeLabelVisibilityInput): boolean;
@@ -1,15 +1,16 @@
1
1
  /**
2
2
  * When the size label under a selection is visible (item B21).
3
3
  */
4
- /** True while the selection is at rest, or between press and the drag threshold. */
4
+ /**
5
+ * True only while the selection is being resized (Figma "Selection Box" keeps the size chip hidden at rest;
6
+ * see 515:623 `hidden` on the component board).
7
+ */
5
8
  export function shouldShowRestingSizeLabel(input) {
6
9
  if (!input.hasFrame)
7
10
  return false;
8
- if (input.overlayDragging === 'move' || input.overlayDragging === 'rotate')
9
- return false;
10
11
  if (input.overlayDragging === 'resize')
11
12
  return true;
12
- if (input.gestureKind === 'resize' || input.gestureKind === 'rotate')
13
+ if (input.gestureKind === 'resize')
13
14
  return true;
14
- return input.gestureKind === null || input.gestureKind === 'move';
15
+ return false;
15
16
  }
@@ -0,0 +1,6 @@
1
+ import type { SelectionTraits } from './selectionTraits.js';
2
+ /**
3
+ * AI-generated widget cards on the board should not open the sketch settings panel (item 17).
4
+ * Sketch shapes and multi-select still use the panel.
5
+ */
6
+ export declare function shouldOfferSelectionPanelForTraits(traits: Pick<SelectionTraits, 'widgetCard' | 'units'>): boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * AI-generated widget cards on the board should not open the sketch settings panel (item 17).
3
+ * Sketch shapes and multi-select still use the panel.
4
+ */
5
+ export function shouldOfferSelectionPanelForTraits(traits) {
6
+ if (traits.widgetCard && traits.units.length === 1)
7
+ return false;
8
+ return traits.units.length > 0;
9
+ }
@@ -211,8 +211,9 @@
211
211
  {/if}
212
212
  </div>
213
213
  {:else if look.type === 'widget'}
214
+ <!-- A live widget covers the card (its screenshot is hidden): no white plate behind the widget's own padding (Figma 526:2706). -->
214
215
  <div
215
- class="pointer-events-none absolute overflow-hidden rounded-lg bg-white"
216
+ class="pointer-events-none absolute overflow-hidden rounded-lg {runtime.hiddenImage ? 'bg-transparent' : 'bg-white'}"
216
217
  style={frameStyle}
217
218
  style:transform={placementOf(object)}
218
219
  data-widget-card={look.widgetId}
@@ -337,6 +337,7 @@
337
337
  class="absolute box-border border-[1.5px] {dragging === 'resize' ? 'border-transparent' : 'border-ring'}"
338
338
  style={screenFrameStyle(frame.screen)}
339
339
  data-canvas-frame
340
+ data-canvas-selection-frame
340
341
  data-dragging={dragging}
341
342
  >
342
343
  {#if dragging === 'resize'}
@@ -32,7 +32,8 @@ export function objectName(object, t) {
32
32
  case 'widget':
33
33
  return t('canvas.type.widget');
34
34
  case 'rect':
35
- return t(object.roundness > 0 ? 'canvas.tool.roundedRectangle' : 'canvas.tool.rectangle');
35
+ // Figma names every rectangle "Rectangle" in the selection panel, including soft corners.
36
+ return t('canvas.tool.rectangle');
36
37
  case 'ellipse':
37
38
  return t(object.aspectLocked ? 'canvas.tool.circle' : 'canvas.tool.ellipse');
38
39
  case 'text':
@@ -94,12 +94,12 @@ export declare const CANVAS_MESSAGES: {
94
94
  readonly 'canvas.action.delete': "Delete";
95
95
  readonly 'canvas.action.group': "Group";
96
96
  readonly 'canvas.action.ungroup': "Ungroup";
97
- readonly 'canvas.action.selectAll': "Select All";
98
- readonly 'canvas.layer.title': "Layer Order";
99
- readonly 'canvas.layer.front': "Bring to Front";
100
- readonly 'canvas.layer.forward': "Bring Forward";
101
- readonly 'canvas.layer.backward': "Send Backward";
102
- readonly 'canvas.layer.back': "Send to Back";
97
+ readonly 'canvas.action.selectAll': "Select all";
98
+ readonly 'canvas.layer.title': "Layer order";
99
+ readonly 'canvas.layer.front': "Bring to front";
100
+ readonly 'canvas.layer.forward': "Bring forward";
101
+ readonly 'canvas.layer.backward': "Send backward";
102
+ readonly 'canvas.layer.back': "Send to back";
103
103
  readonly 'canvas.shortcuts.title': "Keyboard Shortcuts";
104
104
  readonly 'canvas.shortcuts.close': "Close keyboard shortcuts";
105
105
  readonly 'canvas.shortcuts.groupTools': "Tools";
@@ -102,13 +102,13 @@ export const CANVAS_MESSAGES = {
102
102
  'canvas.action.delete': 'Delete',
103
103
  'canvas.action.group': 'Group',
104
104
  'canvas.action.ungroup': 'Ungroup',
105
- 'canvas.action.selectAll': 'Select All',
105
+ 'canvas.action.selectAll': 'Select all',
106
106
  // ===== The order of the layers =====
107
- 'canvas.layer.title': 'Layer Order',
108
- 'canvas.layer.front': 'Bring to Front',
109
- 'canvas.layer.forward': 'Bring Forward',
110
- 'canvas.layer.backward': 'Send Backward',
111
- 'canvas.layer.back': 'Send to Back',
107
+ 'canvas.layer.title': 'Layer order',
108
+ 'canvas.layer.front': 'Bring to front',
109
+ 'canvas.layer.forward': 'Bring forward',
110
+ 'canvas.layer.backward': 'Send backward',
111
+ 'canvas.layer.back': 'Send to back',
112
112
  // ===== The list of keyboard shortcuts =====
113
113
  'canvas.shortcuts.title': 'Keyboard Shortcuts',
114
114
  'canvas.shortcuts.close': 'Close keyboard shortcuts',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/canvas",
3
- "version": "0.5.39",
3
+ "version": "0.5.40",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "svelte": "./dist/index.js",