@widgetic/canvas 0.5.39 → 0.5.41

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 (134) hide show
  1. package/README.md +7 -3
  2. package/dist/canvas/DomCanvas.svelte +7 -3
  3. package/dist/canvas/DomCanvas.svelte.d.ts +8 -0
  4. package/dist/canvas/autosaveScheduler.js +89 -37
  5. package/dist/canvas/boardFrame.js +1 -1
  6. package/dist/canvas/boardSurface.js +1 -1
  7. package/dist/canvas/canvasLogger.js +19 -7
  8. package/dist/canvas/chromeLayout.d.ts +2 -0
  9. package/dist/canvas/chromeLayout.js +31 -17
  10. package/dist/canvas/eventScope.js +14 -10
  11. package/dist/canvas/host/CanvasHost.d.ts +6 -0
  12. package/dist/canvas/host/CanvasHost.js +1556 -1255
  13. package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
  14. package/dist/canvas/host/CanvasHostApi.js +25 -4
  15. package/dist/canvas/host/browserServices.js +116 -65
  16. package/dist/canvas/host/conversion.js +170 -82
  17. package/dist/canvas/host/hostObject.js +7 -7
  18. package/dist/canvas/host/pageEvents.js +4 -4
  19. package/dist/canvas/host/screenRects.js +31 -28
  20. package/dist/canvas/host/strokeSnap.js +143 -88
  21. package/dist/canvas/openMarks.js +2 -2
  22. package/dist/canvas/outsideClickDeselect.js +7 -6
  23. package/dist/canvas/panZoomPosition.js +2 -2
  24. package/dist/canvas/preferredTextFont.js +25 -13
  25. package/dist/canvas/shapes/ShapeLibrary.js +148 -138
  26. package/dist/canvas/shapes/shapeImageStore.js +3 -3
  27. package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
  28. package/dist/canvas/toolbarPosition.js +2 -2
  29. package/dist/canvas/ui/CanvasContextMenu.svelte +69 -39
  30. package/dist/canvas/ui/CanvasHint.svelte +17 -4
  31. package/dist/canvas/ui/CanvasHint.svelte.d.ts +2 -17
  32. package/dist/canvas/ui/CanvasToolbar.svelte +27 -10
  33. package/dist/canvas/ui/ColorField.svelte +1 -1
  34. package/dist/canvas/ui/SelectionPanel.svelte +24 -20
  35. package/dist/canvas/ui/ShapesMenu.svelte +0 -2
  36. package/dist/canvas/ui/ToolButton.svelte +11 -3
  37. package/dist/canvas/ui/ToolButton.svelte.d.ts +2 -0
  38. package/dist/canvas/ui/WidgetActions.svelte +1 -1
  39. package/dist/canvas/ui/ZoomControl.svelte +39 -4
  40. package/dist/canvas/ui/ZoomControl.svelte.d.ts +2 -2
  41. package/dist/canvas/ui/colorModel.js +32 -21
  42. package/dist/canvas/ui/colorPickerMessages.js +5 -5
  43. package/dist/canvas/ui/floatingCard.d.ts +7 -5
  44. package/dist/canvas/ui/floatingCard.js +23 -21
  45. package/dist/canvas/ui/floatingLayer.js +6 -5
  46. package/dist/canvas/ui/keyHints.d.ts +5 -0
  47. package/dist/canvas/ui/keyHints.js +23 -7
  48. package/dist/canvas/ui/popoverSide.js +3 -2
  49. package/dist/canvas/ui/selectionTraits.js +40 -34
  50. package/dist/canvas/ui/sizeLabelVisibility.d.ts +5 -2
  51. package/dist/canvas/ui/sizeLabelVisibility.js +7 -6
  52. package/dist/canvas/ui/widgetSelectionPanel.d.ts +6 -0
  53. package/dist/canvas/ui/widgetSelectionPanel.js +9 -0
  54. package/dist/canvas/view/ObjectView.svelte +2 -1
  55. package/dist/canvas/view/SelectionOverlay.svelte +34 -14
  56. package/dist/canvas/view/erasingMarks.js +7 -7
  57. package/dist/canvas/view/geometry.d.ts +14 -4
  58. package/dist/canvas/view/geometry.js +103 -77
  59. package/dist/components/preferenceStorage.js +2 -2
  60. package/dist/engine/EngineCore.d.ts +4 -1
  61. package/dist/engine/EngineCore.js +801 -695
  62. package/dist/engine/codec/canvasDocument.js +173 -173
  63. package/dist/engine/codec/hostReadableKeys.js +1 -1
  64. package/dist/engine/core/arrange.js +38 -26
  65. package/dist/engine/core/arrow.d.ts +10 -3
  66. package/dist/engine/core/arrow.js +96 -75
  67. package/dist/engine/core/arrowBinding.d.ts +69 -0
  68. package/dist/engine/core/arrowBinding.js +344 -0
  69. package/dist/engine/core/arrowBindingRecords.d.ts +43 -0
  70. package/dist/engine/core/arrowBindingRecords.js +141 -0
  71. package/dist/engine/core/brush.js +94 -67
  72. package/dist/engine/core/defaults.js +51 -90
  73. package/dist/engine/core/freehand.js +163 -147
  74. package/dist/engine/core/geometry.js +54 -47
  75. package/dist/engine/core/history.js +50 -33
  76. package/dist/engine/core/hitTest.d.ts +3 -0
  77. package/dist/engine/core/hitTest.js +83 -69
  78. package/dist/engine/core/matrix.js +20 -18
  79. package/dist/engine/core/pathData.js +210 -183
  80. package/dist/engine/core/rotationReset.js +6 -5
  81. package/dist/engine/core/scene.d.ts +3 -0
  82. package/dist/engine/core/scene.js +192 -129
  83. package/dist/engine/core/scribble.js +84 -59
  84. package/dist/engine/core/shapePaths.js +15 -12
  85. package/dist/engine/core/shapeTools.js +63 -72
  86. package/dist/engine/core/snapping.js +117 -65
  87. package/dist/engine/core/style.js +64 -31
  88. package/dist/engine/core/transform.js +94 -83
  89. package/dist/engine/core/types.d.ts +29 -0
  90. package/dist/engine/core/types.js +4 -4
  91. package/dist/engine/core/viewport.js +36 -23
  92. package/dist/engine/input/PointerController.js +476 -447
  93. package/dist/engine/input/arrowHandles.js +12 -12
  94. package/dist/engine/input/gestures.d.ts +12 -1
  95. package/dist/engine/input/gestures.js +342 -251
  96. package/dist/engine/input/hoverCursor.js +1 -1
  97. package/dist/engine/input/keyboard.d.ts +9 -1
  98. package/dist/engine/input/keyboard.js +46 -27
  99. package/dist/engine/input/selectionHandles.js +50 -45
  100. package/dist/engine/input/types.js +1 -1
  101. package/dist/engine/render/rasterize.js +158 -86
  102. package/dist/engine/state.d.ts +6 -1
  103. package/dist/engine/state.js +17 -5
  104. package/dist/engine/text/layoutText.js +62 -43
  105. package/dist/engine/text/textMetrics.js +10 -8
  106. package/dist/engine/widgets.js +137 -101
  107. package/dist/fonts/interFont.js +68 -17
  108. package/dist/fonts/workspaceFonts.js +90 -32
  109. package/dist/i18n/labels.js +6 -5
  110. package/dist/i18n/language.js +4 -4
  111. package/dist/i18n/messages.d.ts +6 -6
  112. package/dist/i18n/messages.js +7 -7
  113. package/dist/i18n/shortcuts.d.ts +12 -0
  114. package/dist/i18n/shortcuts.js +32 -18
  115. package/dist/settings/workspaceToolSettings.js +48 -32
  116. package/dist/tools/components/catalog.d.ts +11 -0
  117. package/dist/tools/components/catalog.js +270 -0
  118. package/dist/tools/components/grouping.d.ts +9 -0
  119. package/dist/tools/components/grouping.js +33 -0
  120. package/dist/tools/definitions.d.ts +19 -0
  121. package/dist/tools/definitions.js +147 -0
  122. package/dist/tools/executors.d.ts +7 -0
  123. package/dist/tools/executors.js +324 -0
  124. package/dist/tools/hostAdapter.d.ts +14 -0
  125. package/dist/tools/hostAdapter.js +40 -0
  126. package/dist/tools/index.d.ts +6 -0
  127. package/dist/tools/index.js +6 -0
  128. package/dist/tools/sceneSummary.d.ts +24 -0
  129. package/dist/tools/sceneSummary.js +170 -0
  130. package/dist/tools/sketchIntent.d.ts +17 -0
  131. package/dist/tools/sketchIntent.js +166 -0
  132. package/dist/tools/types.d.ts +54 -0
  133. package/dist/tools/types.js +11 -0
  134. package/package.json +7 -2
@@ -11,9 +11,9 @@
11
11
  */
12
12
  import { CHROME_ANCHORS, normalizeAnchor } from './chromeLayout.js';
13
13
  /** The places the toolbar can stand: `TL TC TR` (top), `CL CR` (the sides) and `BL BC BR` (bottom). */
14
- export const TOOLBAR_POSITIONS = CHROME_ANCHORS;
14
+ export var TOOLBAR_POSITIONS = CHROME_ANCHORS;
15
15
  /** Where the toolbar stands when the host says nothing: the bottom centre, as it always did. */
16
- export const DEFAULT_TOOLBAR_POSITION = 'BC';
16
+ export var DEFAULT_TOOLBAR_POSITION = 'BC';
17
17
  /**
18
18
  * The position to use for what a host passed. Anything that is not one of the eight (the middle of the board, a word in
19
19
  * lower case, nothing at all) is the default, so that a mistake in the host's option never takes the toolbar off the
@@ -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}
@@ -1,21 +1,34 @@
1
1
  <!--
2
2
  Figma "Canvas Hint": what an empty board says. A 40 px tile with a pencil, a title and one line under it, centred on the
3
3
  board and never in the way of the pointer. It is shown while the board holds nothing, and goes the moment something is
4
- drawn.
4
+ drawn. A page that words the line under the title as an empty message (`messages`) gets the tile and the title only.
5
+
6
+ Where it stands: in the middle of the board above the toolbar (the toolbar is 44 px high and stands 16 px from the bottom,
7
+ so the room above it ends 60 px from the bottom), so a short board such as the 320 px card of the Home page shows the whole
8
+ hint. Figma puts it 312 px from the top of a tall board and it stays there: the space over the hint is capped at 312 px,
9
+ the rest goes under it. A phone (max-md) centres it on the whole board, as before.
5
10
  -->
6
11
  <script lang="ts">
7
12
  import { useCanvasLanguage } from '../../i18n/language.js';
8
13
  import { IconPencil } from './icons.js';
9
14
 
10
15
  const { t } = useCanvasLanguage();
16
+
17
+ // The line under the title. Empty when the page left it out: the line is then not drawn at all, so it leaves no gap either.
18
+ const hintDescription = $derived($t('canvas.hint.description'));
11
19
  </script>
12
20
 
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">
21
+ <div class="pointer-events-none absolute inset-x-0 top-0 bottom-[60px] flex flex-col items-center max-md:inset-0 max-md:justify-center max-md:p-6" data-canvas-hint>
22
+ <!-- The space over the hint and the space under it share what the board has left; the one over it never grows past 312 px. -->
23
+ <div class="max-h-[312px] min-h-0 flex-1 max-md:hidden"></div>
24
+ <div class="flex w-80 max-w-full flex-col items-center gap-2.5 text-center">
15
25
  <div class="flex size-9 items-center justify-center rounded-lg border border-border bg-background text-foreground">
16
26
  <IconPencil class="size-4 stroke-[1.333]" aria-hidden="true" />
17
27
  </div>
18
28
  <p class="text-body-medium text-foreground">{$t('canvas.hint.title')}</p>
19
- <p class="text-body text-muted-foreground">{$t('canvas.hint.description')}</p>
29
+ {#if hintDescription}
30
+ <p class="text-body text-muted-foreground" data-canvas-hint-description>{hintDescription}</p>
31
+ {/if}
20
32
  </div>
33
+ <div class="min-h-0 flex-1 max-md:hidden"></div>
21
34
  </div>
@@ -1,18 +1,3 @@
1
- interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
- new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
- $$bindings?: Bindings;
4
- } & Exports;
5
- (internal: unknown, props: {
6
- $$events?: Events;
7
- $$slots?: Slots;
8
- }): Exports & {
9
- $set?: any;
10
- $on?: any;
11
- };
12
- z_$$bindings?: Bindings;
13
- }
14
- declare const CanvasHint: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
15
- [evt: string]: CustomEvent<any>;
16
- }, {}, {}, string>;
17
- type CanvasHint = InstanceType<typeof CanvasHint>;
1
+ declare const CanvasHint: import("svelte").Component<Record<string, never>, {}, "">;
2
+ type CanvasHint = ReturnType<typeof CanvasHint>;
18
3
  export default CanvasHint;
@@ -4,7 +4,7 @@
4
4
 
5
5
  Left to right: the drawing group (select, draw, erase, arrow, text), a divider, the Shapes menu, a divider and the history
6
6
  group (undo, redo). Every button is the design system's Icon Button with a tooltip, 36 px square, and the tool in use has
7
- the brand tint. The page's `showDrawingTools` hides the drawing group (and with it the letters that choose those tools).
7
+ the brand tint. The page's `showDrawingTools` hides the drawing group (and with it the letters and numbers that choose those tools).
8
8
  The Shapes menu and the history group are always on the bar: a page that wants a leaner canvas hides the bar itself. On a
9
9
  board narrower than the whole bar and its edges (381 px, so Figma's 358 px phone) the history group leaves the bar.
10
10
 
@@ -18,11 +18,11 @@
18
18
  import { Separator } from '@widgetic/design-system/components';
19
19
  import type { EngineState } from '../../engine/state.js';
20
20
  import { useCanvasLanguage } from '../../i18n/language.js';
21
- import { TOOL_KEYS } from '../../i18n/shortcuts.js';
21
+ import { TOOL_DIGIT_KEYS, TOOL_KEYS } from '../../i18n/shortcuts.js';
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,23 +52,23 @@
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}
59
- <ToolButton toggle label={$t('canvas.tool.select')} shortcut={TOOL_KEYS.select} active={state.tool === 'select'} onclick={() => host.onSelectSelectTool()}>
59
+ <ToolButton toggle label={$t('canvas.tool.select')} shortcut={TOOL_KEYS.select} alternateShortcut={TOOL_DIGIT_KEYS.select} active={state.tool === 'select'} onclick={() => host.onSelectSelectTool()}>
60
60
  <IconPointer />
61
61
  </ToolButton>
62
- <ToolButton toggle label={$t('canvas.tool.draw')} shortcut={TOOL_KEYS.draw} active={state.tool === 'draw'} onclick={() => host.onSelectDrawTool()}>
62
+ <ToolButton toggle label={$t('canvas.tool.draw')} shortcut={TOOL_KEYS.draw} alternateShortcut={TOOL_DIGIT_KEYS.draw} active={state.tool === 'draw'} onclick={() => host.onSelectDrawTool()}>
63
63
  <IconPencil />
64
64
  </ToolButton>
65
- <ToolButton toggle label={$t('canvas.tool.erase')} shortcut={TOOL_KEYS.erase} active={state.tool === 'erase'} onclick={() => host.onSelectEraseTool()}>
65
+ <ToolButton toggle label={$t('canvas.tool.erase')} shortcut={TOOL_KEYS.erase} alternateShortcut={TOOL_DIGIT_KEYS.erase} active={state.tool === 'erase'} onclick={() => host.onSelectEraseTool()}>
66
66
  <IconEraser />
67
67
  </ToolButton>
68
- <ToolButton toggle label={$t('canvas.tool.arrow')} shortcut={TOOL_KEYS.arrow} active={state.tool === 'arrow'} onclick={() => host.onSelectArrowTool()}>
68
+ <ToolButton toggle label={$t('canvas.tool.arrow')} shortcut={TOOL_KEYS.arrow} alternateShortcut={TOOL_DIGIT_KEYS.arrow} active={state.tool === 'arrow'} onclick={() => host.onSelectArrowTool()}>
69
69
  <IconArrowUpRight />
70
70
  </ToolButton>
71
- <ToolButton toggle label={$t('canvas.tool.text')} shortcut={TOOL_KEYS.text} active={state.tool === 'text'} onclick={() => host.onSelectTextTool()}>
71
+ <ToolButton toggle label={$t('canvas.tool.text')} shortcut={TOOL_KEYS.text} alternateShortcut={TOOL_DIGIT_KEYS.text} active={state.tool === 'text'} onclick={() => host.onSelectTextTool()}>
72
72
  <IconTypography />
73
73
  </ToolButton>
74
74
 
@@ -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 />
@@ -17,6 +17,8 @@
17
17
  label: string;
18
18
  /** The key that does the same, as it is printed on a key cap ("V"), or nothing. It is also the button's `aria-keyshortcuts`. */
19
19
  shortcut?: string | undefined;
20
+ /** A second key that does the same ("1", the number of the tool): a second key cap in the tooltip, and a second entry of `aria-keyshortcuts`. */
21
+ alternateShortcut?: string | undefined;
20
22
  /** The tool this button chooses is the one in use. */
21
23
  active?: boolean;
22
24
  /** Whether the button acts like a switch (it then says whether it is on to a screen reader). */
@@ -29,7 +31,10 @@
29
31
  children: Snippet;
30
32
  }
31
33
 
32
- let { label, shortcut = undefined, active = false, toggle = false, disabled = false, size = 'toolbar', class: className = '', onclick, children }: Props = $props();
34
+ let { label, shortcut = undefined, alternateShortcut = undefined, active = false, toggle = false, disabled = false, size = 'toolbar', class: className = '', onclick, children }: Props = $props();
35
+
36
+ // `aria-keyshortcuts` lists the keys that do the same, separated by a space ("V 1").
37
+ const keyShortcuts = $derived([shortcut, alternateShortcut].filter(Boolean).join(' ') || undefined);
33
38
 
34
39
  // The tooltip is drawn into the canvas's floating layer, not in place: see floatingLayer.ts.
35
40
  const floatingLayer = useFloatingLayer();
@@ -46,7 +51,7 @@
46
51
  <Tooltip.Trigger>
47
52
  {#snippet child({ props }: { props: Record<string, unknown> })}
48
53
  {#if size === 'level'}
49
- <button {...props} type="button" aria-label={label} aria-keyshortcuts={shortcut} {disabled} {onclick} class="{LEVEL_CLASSES} {className}">
54
+ <button {...props} type="button" aria-label={label} aria-keyshortcuts={keyShortcuts} {disabled} {onclick} class="{LEVEL_CLASSES} {className}">
50
55
  {@render children()}
51
56
  </button>
52
57
  {:else}
@@ -56,7 +61,7 @@
56
61
  {disabled}
57
62
  {onclick}
58
63
  aria-pressed={toggle ? active : undefined}
59
- aria-keyshortcuts={shortcut}
64
+ aria-keyshortcuts={keyShortcuts}
60
65
  data-active={active ? '' : undefined}
61
66
  class="{SQUARE_CLASSES[size]} data-[active]:bg-brand-subtle data-[active]:text-foreground {className}"
62
67
  >
@@ -72,6 +77,9 @@
72
77
  {#if shortcut}
73
78
  <kbd class="rounded-sm bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{shortcut}</kbd>
74
79
  {/if}
80
+ {#if alternateShortcut}
81
+ <kbd class="rounded-sm bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{alternateShortcut}</kbd>
82
+ {/if}
75
83
  </span>
76
84
  </Tooltip.Content>
77
85
  </Tooltip.Portal>
@@ -4,6 +4,8 @@ interface Props {
4
4
  label: string;
5
5
  /** The key that does the same, as it is printed on a key cap ("V"), or nothing. It is also the button's `aria-keyshortcuts`. */
6
6
  shortcut?: string | undefined;
7
+ /** A second key that does the same ("1", the number of the tool): a second key cap in the tooltip, and a second entry of `aria-keyshortcuts`. */
8
+ alternateShortcut?: string | undefined;
7
9
  /** The tool this button chooses is the one in use. */
8
10
  active?: boolean;
9
11
  /** Whether the button acts like a switch (it then says whether it is on to a screen reader). */
@@ -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;