@widgetic/canvas 0.5.44 → 0.5.45
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.
- package/dist/canvas/DomCanvas.svelte +52 -3
- package/dist/canvas/DomCanvas.svelte.d.ts +59 -34
- package/dist/canvas/autosaveScheduler.js +89 -37
- package/dist/canvas/boardFrame.js +1 -1
- package/dist/canvas/boardSurface.js +1 -1
- package/dist/canvas/canvasLogger.js +19 -7
- package/dist/canvas/chromeLayout.js +21 -19
- package/dist/canvas/eventScope.js +14 -10
- package/dist/canvas/host/CanvasHost.d.ts +68 -1
- package/dist/canvas/host/CanvasHost.js +1901 -1407
- package/dist/canvas/host/CanvasHostApi.d.ts +2 -2
- package/dist/canvas/host/CanvasHostApi.js +28 -5
- package/dist/canvas/host/boardFiles.d.ts +90 -0
- package/dist/canvas/host/boardFiles.js +155 -0
- package/dist/canvas/host/browserServices.d.ts +17 -0
- package/dist/canvas/host/browserServices.js +211 -65
- package/dist/canvas/host/conversion.js +170 -82
- package/dist/canvas/host/hostObject.js +7 -7
- package/dist/canvas/host/nearCards.js +21 -18
- package/dist/canvas/host/pageEvents.js +5 -5
- package/dist/canvas/host/pictureSaves.js +11 -9
- package/dist/canvas/host/screenRects.js +31 -28
- package/dist/canvas/host/storedPictures.js +243 -149
- package/dist/canvas/host/strokeSnap.js +143 -88
- package/dist/canvas/index.d.ts +1 -0
- package/dist/canvas/openMarks.js +2 -2
- package/dist/canvas/outsideClickDeselect.js +7 -6
- package/dist/canvas/panZoomPosition.js +2 -2
- package/dist/canvas/preferredTextFont.js +25 -13
- package/dist/canvas/shapes/ShapeLibrary.js +148 -138
- package/dist/canvas/shapes/shapeImageStore.js +4 -4
- package/dist/canvas/shapes/strokeShapeSnap.js +233 -188
- package/dist/canvas/toolbarPosition.js +2 -2
- package/dist/canvas/ui/CanvasContextMenu.svelte +7 -0
- package/dist/canvas/ui/CanvasToolbar.svelte +4 -1
- package/dist/canvas/ui/CanvasToolbar.svelte.d.ts +2 -0
- package/dist/canvas/ui/SelectionPanel.svelte +78 -17
- package/dist/canvas/ui/ShapesMenu.svelte +65 -31
- package/dist/canvas/ui/ShapesMenu.svelte.d.ts +2 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte +64 -0
- package/dist/canvas/ui/ShortcutTooltip.svelte.d.ts +24 -0
- package/dist/canvas/ui/ToolButton.svelte +34 -55
- package/dist/canvas/ui/ToolButton.svelte.d.ts +4 -1
- package/dist/canvas/ui/colorModel.js +32 -21
- package/dist/canvas/ui/colorPickerMessages.js +5 -5
- package/dist/canvas/ui/floatingCard.d.ts +26 -4
- package/dist/canvas/ui/floatingCard.js +43 -21
- package/dist/canvas/ui/floatingLayer.js +6 -5
- package/dist/canvas/ui/icons.d.ts +1 -1
- package/dist/canvas/ui/icons.js +1 -1
- package/dist/canvas/ui/keyHints.js +11 -9
- package/dist/canvas/ui/popoverSide.js +3 -2
- package/dist/canvas/ui/selectionTraits.d.ts +12 -0
- package/dist/canvas/ui/selectionTraits.js +66 -35
- package/dist/canvas/ui/sizeLabelVisibility.d.ts +4 -2
- package/dist/canvas/ui/sizeLabelVisibility.js +5 -5
- package/dist/canvas/view/CanvasStage.svelte +7 -2
- package/dist/canvas/view/CanvasStage.svelte.d.ts +2 -0
- package/dist/canvas/view/SelectionOverlay.svelte +17 -10
- package/dist/canvas/view/WidgetChromeLayer.svelte +15 -3
- package/dist/canvas/view/erasingMarks.js +7 -7
- package/dist/canvas/view/geometry.d.ts +1 -1
- package/dist/canvas/view/geometry.js +90 -71
- package/dist/canvas/view/liftedScene.js +36 -24
- package/dist/canvas/view/mountedScene.js +79 -76
- package/dist/components/CanvasBoardPoster.svelte +206 -0
- package/dist/components/CanvasBoardPoster.svelte.d.ts +17 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte +115 -0
- package/dist/components/CanvasToolbarPlaceholder.svelte.d.ts +9 -0
- package/dist/components/index.d.ts +7 -0
- package/dist/components/index.js +8 -0
- package/dist/components/preferenceStorage.js +2 -2
- package/dist/engine/EngineCore.d.ts +37 -2
- package/dist/engine/EngineCore.js +946 -768
- package/dist/engine/codec/canvasDocument.d.ts +7 -0
- package/dist/engine/codec/canvasDocument.js +172 -186
- package/dist/engine/codec/hostReadableKeys.js +1 -1
- package/dist/engine/core/arrange.js +38 -26
- package/dist/engine/core/arrow.d.ts +18 -8
- package/dist/engine/core/arrow.js +109 -84
- package/dist/engine/core/arrowBinding.d.ts +1 -1
- package/dist/engine/core/arrowBinding.js +126 -101
- package/dist/engine/core/arrowBindingRecords.d.ts +9 -3
- package/dist/engine/core/arrowBindingRecords.js +48 -29
- package/dist/engine/core/brush.d.ts +8 -0
- package/dist/engine/core/brush.js +98 -78
- package/dist/engine/core/cameraMove.d.ts +6 -0
- package/dist/engine/core/cameraMove.js +56 -38
- package/dist/engine/core/defaults.js +51 -90
- package/dist/engine/core/freehand.js +163 -147
- package/dist/engine/core/geometry.js +54 -47
- package/dist/engine/core/history.js +55 -38
- package/dist/engine/core/hitTest.js +81 -68
- package/dist/engine/core/matrix.js +20 -18
- package/dist/engine/core/pathData.js +210 -183
- package/dist/engine/core/rotationReset.js +6 -5
- package/dist/engine/core/scene.d.ts +22 -0
- package/dist/engine/core/scene.js +288 -139
- package/dist/engine/core/scribble.js +84 -59
- package/dist/engine/core/shapePaths.js +15 -12
- package/dist/engine/core/shapeTools.js +63 -72
- package/dist/engine/core/snapping.js +117 -65
- package/dist/engine/core/style.d.ts +10 -0
- package/dist/engine/core/style.js +82 -33
- package/dist/engine/core/transform.d.ts +6 -0
- package/dist/engine/core/transform.js +103 -83
- package/dist/engine/core/types.d.ts +7 -0
- package/dist/engine/core/types.js +4 -4
- package/dist/engine/core/viewport.js +36 -23
- package/dist/engine/input/PointerController.d.ts +15 -1
- package/dist/engine/input/PointerController.js +547 -476
- package/dist/engine/input/arrowHandles.js +12 -12
- package/dist/engine/input/gestures.d.ts +3 -1
- package/dist/engine/input/gestures.js +340 -266
- package/dist/engine/input/hoverCursor.js +1 -1
- package/dist/engine/input/keyboard.d.ts +22 -3
- package/dist/engine/input/keyboard.js +131 -32
- package/dist/engine/input/selectionHandles.js +50 -45
- package/dist/engine/input/types.d.ts +7 -0
- package/dist/engine/input/types.js +1 -1
- package/dist/engine/render/rasterize.js +158 -86
- package/dist/engine/state.d.ts +18 -0
- package/dist/engine/state.js +25 -4
- package/dist/engine/text/layoutText.js +62 -43
- package/dist/engine/text/textMetrics.js +10 -8
- package/dist/engine/widgets.js +137 -101
- package/dist/fonts/interFont.js +83 -30
- package/dist/fonts/workspaceFonts.d.ts +6 -0
- package/dist/fonts/workspaceFonts.js +108 -34
- package/dist/i18n/labels.js +4 -4
- package/dist/i18n/language.d.ts +3 -3
- package/dist/i18n/language.js +4 -4
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/i18n/messages.js +7 -1
- package/dist/i18n/shortcuts.d.ts +6 -4
- package/dist/i18n/shortcuts.js +30 -26
- package/dist/index.d.ts +1 -0
- package/dist/poster/boardPlacement.d.ts +80 -0
- package/dist/poster/boardPlacement.js +140 -0
- package/dist/poster/boardPoster.d.ts +80 -0
- package/dist/poster/boardPoster.js +251 -0
- package/dist/poster/paintBoardPoster.d.ts +49 -0
- package/dist/poster/paintBoardPoster.js +112 -0
- package/dist/poster/posterPictures.d.ts +32 -0
- package/dist/poster/posterPictures.js +138 -0
- package/dist/settings/workspaceToolSettings.d.ts +6 -0
- package/dist/settings/workspaceToolSettings.js +58 -34
- package/dist/tools/components/catalog.js +74 -64
- package/dist/tools/components/grouping.js +28 -6
- package/dist/tools/definitions.js +31 -9
- package/dist/tools/executors.js +214 -106
- package/dist/tools/hostAdapter.d.ts +5 -1
- package/dist/tools/hostAdapter.js +15 -11
- package/dist/tools/sceneSummary.js +57 -43
- package/dist/tools/sketchIntent.js +21 -13
- package/dist/tools/styleArguments.d.ts +35 -0
- package/dist/tools/styleArguments.js +93 -0
- package/dist/tools/types.d.ts +26 -1
- package/dist/tools/types.js +2 -1
- package/package.json +1 -1
|
@@ -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
|
|
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
|
|
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
|
|
@@ -141,6 +141,12 @@
|
|
|
141
141
|
</DropdownMenu.Item>
|
|
142
142
|
{/snippet}
|
|
143
143
|
|
|
144
|
+
<!--
|
|
145
|
+
`data-canvas-ui` marks the menu as the canvas's own (its layer submenu sits inside it): on a page without a shadow root the
|
|
146
|
+
menu is portaled to `document.body`, outside the canvas root, and a press on one of its entries would otherwise count as a
|
|
147
|
+
press outside the canvas (`outsideClickDeselect.ts`) and clear the selection before the click lands. The entries that act
|
|
148
|
+
on the selection (Duplicate, Bring to front, Delete...) are disabled by then, and nothing happens.
|
|
149
|
+
-->
|
|
144
150
|
<DropdownMenu.Root open={point !== null} onOpenChange={setOpen}>
|
|
145
151
|
{#if anchor}
|
|
146
152
|
<DropdownMenu.Content
|
|
@@ -151,6 +157,7 @@
|
|
|
151
157
|
portalProps={canvasOverlayPortalProps($floatingLayer)}
|
|
152
158
|
onCloseAutoFocus={returnFocusToBoard}
|
|
153
159
|
aria-label={$t('canvas.panel.actions')}
|
|
160
|
+
data-canvas-ui
|
|
154
161
|
data-canvas-context-menu
|
|
155
162
|
class="{CANVAS_OVERLAY_Z_CLASS} w-[240px] py-1 {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}"
|
|
156
163
|
>
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
state: EngineState;
|
|
34
34
|
ui: HostUiState;
|
|
35
35
|
showDrawingTools: boolean;
|
|
36
|
+
/** Whether the Shapes menu offers the person's file library (the page turned it on and gave the browser that opens it). */
|
|
37
|
+
showFiles?: boolean;
|
|
36
38
|
/** Where the bar stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
|
|
37
39
|
anchor: ChromeAnchor;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
|
-
let { host, state, ui, showDrawingTools, anchor }: Props = $props();
|
|
42
|
+
let { host, state, ui, showDrawingTools, showFiles = false, anchor }: Props = $props();
|
|
41
43
|
|
|
42
44
|
const { t } = useCanvasLanguage();
|
|
43
45
|
|
|
@@ -81,6 +83,7 @@
|
|
|
81
83
|
libraryShapeKey={state.libraryShapeKey}
|
|
82
84
|
open={ui.shapesMenuOpen}
|
|
83
85
|
imageShortcut={TOOL_KEYS.image}
|
|
86
|
+
{showFiles}
|
|
84
87
|
/>
|
|
85
88
|
|
|
86
89
|
<!-- 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. -->
|
|
@@ -6,6 +6,8 @@ interface Props {
|
|
|
6
6
|
state: EngineState;
|
|
7
7
|
ui: HostUiState;
|
|
8
8
|
showDrawingTools: boolean;
|
|
9
|
+
/** Whether the Shapes menu offers the person's file library (the page turned it on and gave the browser that opens it). */
|
|
10
|
+
showFiles?: boolean;
|
|
9
11
|
/** Where the bar stands (see `chromeLayout.ts`): it stands upright on the left and the right edge. */
|
|
10
12
|
anchor: ChromeAnchor;
|
|
11
13
|
}
|
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
Every change goes through the engine's one `setStyle`, so what the panel does is what an undo takes back, and a slider that
|
|
11
11
|
is still being dragged is one step of the history, taken when it ends.
|
|
12
12
|
|
|
13
|
+
With the Draw tool chosen and nothing selected the panel is about the pen: the line the next stroke is drawn with. It has
|
|
14
|
+
the rows a line drawn by hand has (Stroke, Stroke width and Opacity), and what is set there is what the next line looks like,
|
|
15
|
+
before anything is drawn (see `describePenStyle`). Nothing that is drawn already changes, and the pen is kept for the
|
|
16
|
+
workspace (see `CanvasHost.changePenStyle`). It opens and closes like the panel of a selection.
|
|
17
|
+
|
|
13
18
|
A selection shows a settings control at the corner; it opens the panel, and the close button collapses it again without
|
|
14
19
|
changing when the selection changes. Nothing opens the panel by itself, not a selection and not a text: it is closed by
|
|
15
20
|
default, it stays as the person left it while the selection moves from one object to another, and it goes back to the
|
|
@@ -21,8 +26,10 @@
|
|
|
21
26
|
import { onDestroy } from 'svelte';
|
|
22
27
|
import type { Attachment } from 'svelte/attachments';
|
|
23
28
|
import { IconButton, NumberControls, Select, Slider } from '@widgetic/design-system/components';
|
|
29
|
+
import { MIN_BRUSH_WIDTH } from '../../engine/core/brush.js';
|
|
24
30
|
import type { StylePatch } from '../../engine/core/style.js';
|
|
25
|
-
import
|
|
31
|
+
import { MIN_PEN_OPACITY } from '../../engine/state.js';
|
|
32
|
+
import type { EngineState, PenStyle } from '../../engine/state.js';
|
|
26
33
|
import { useCanvasLanguage } from '../../i18n/language.js';
|
|
27
34
|
import { objectName } from '../../i18n/labels.js';
|
|
28
35
|
import type { PanelClearance } from '../chromeLayout.js';
|
|
@@ -37,7 +44,15 @@
|
|
|
37
44
|
workspaceFontFamiliesForPicker,
|
|
38
45
|
writePreferredTextFontFamily
|
|
39
46
|
} from '../preferredTextFont.js';
|
|
40
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
describePenStyle,
|
|
49
|
+
describeSelection,
|
|
50
|
+
formatFontSizeDisplay,
|
|
51
|
+
minimumStrokeWidth,
|
|
52
|
+
showFillColorRow,
|
|
53
|
+
showStrokeColorRow,
|
|
54
|
+
traitNumber
|
|
55
|
+
} from './selectionTraits.js';
|
|
41
56
|
import ToolButton from './ToolButton.svelte';
|
|
42
57
|
import WidgetActions from './WidgetActions.svelte';
|
|
43
58
|
import { shouldOfferSelectionPanelForTraits } from './widgetSelectionPanel.js';
|
|
@@ -76,12 +91,27 @@
|
|
|
76
91
|
const PANEL_END_BESIDE_SIDE_CARD = { toolbar: '5.25rem', zoom: '4rem' } as const;
|
|
77
92
|
const PANEL_MAX_WIDTH_CLASSES = { none: 'max-w-[calc(100%-2rem)]', toolbar: 'max-w-[calc(100%-6.25rem)]', zoom: 'max-w-[calc(100%-5rem)]' } as const;
|
|
78
93
|
|
|
79
|
-
|
|
94
|
+
// ── the pen
|
|
95
|
+
// With the Draw tool chosen and nothing selected, the panel is about the pen: the line the next stroke is drawn with (see
|
|
96
|
+
// `EngineState.penStyle`). It offers what a line drawn by hand has (its colour, its width and how much of the board shows
|
|
97
|
+
// through it), so that these can be set before anything is drawn. A selection is about the selection, whatever the tool is.
|
|
98
|
+
const editsPen = $derived(state.tool === 'draw' && state.selectedIds.length === 0);
|
|
99
|
+
|
|
100
|
+
const traits = $derived(editsPen ? describePenStyle(state.penStyle) : describeSelection(state.scene, state.selectedIds));
|
|
80
101
|
const hasSelection = $derived(traits.units.length > 0);
|
|
81
102
|
|
|
82
103
|
const title = $derived(
|
|
83
|
-
|
|
104
|
+
editsPen
|
|
105
|
+
? $t('canvas.tool.draw')
|
|
106
|
+
: traits.units.length === 1
|
|
107
|
+
? objectName(traits.units[0], $t)
|
|
108
|
+
: hasSelection
|
|
109
|
+
? $t('canvas.type.selection')
|
|
110
|
+
: $t('canvas.panel.actions')
|
|
84
111
|
);
|
|
112
|
+
// The name of the panel and of the control that opens it, for a screen reader: the pen is not a selection.
|
|
113
|
+
const panelLabel = $derived(editsPen ? $t('canvas.panel.penLabel') : $t('canvas.panel.label'));
|
|
114
|
+
const openLabel = $derived(editsPen ? $t('canvas.panel.penOpen') : $t('canvas.panel.open'));
|
|
85
115
|
|
|
86
116
|
// The font of a text, offered as the old panel offered it: eight families that every screen has.
|
|
87
117
|
const WORKSPACE_FONT_FAMILIES = $derived(workspaceFontFamiliesForPicker());
|
|
@@ -98,8 +128,24 @@
|
|
|
98
128
|
commitTimer = undefined;
|
|
99
129
|
}
|
|
100
130
|
|
|
101
|
-
/**
|
|
131
|
+
/**
|
|
132
|
+
* Sets the pen (see `editsPen`): of the keys of a change of style a line takes its colour (`stroke`), its width and its opacity.
|
|
133
|
+
* The pen is not on the board, so there is no step of the history to take and nothing to commit; `final` is false while a drag is going.
|
|
134
|
+
*/
|
|
135
|
+
function changePen(patch: StylePatch, final: boolean): void {
|
|
136
|
+
const penPatch: Partial<PenStyle> = {};
|
|
137
|
+
if (patch.stroke !== undefined) penPatch.color = patch.stroke;
|
|
138
|
+
if (patch.strokeWidth !== undefined) penPatch.width = patch.strokeWidth;
|
|
139
|
+
if (patch.opacity !== undefined) penPatch.opacity = patch.opacity;
|
|
140
|
+
host.changePenStyle(penPatch, { final });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Changes how the selection looks (or the pen, while the panel is about the pen). `commit` is false while a drag is going. */
|
|
102
144
|
function changeStyle(patch: StylePatch, commit = true): void {
|
|
145
|
+
if (editsPen) {
|
|
146
|
+
changePen(patch, commit);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
103
149
|
try {
|
|
104
150
|
host.engine.setStyle(patch, { commit });
|
|
105
151
|
stopCommitTimer();
|
|
@@ -115,7 +161,9 @@
|
|
|
115
161
|
|
|
116
162
|
function endChange(): void {
|
|
117
163
|
stopCommitTimer();
|
|
118
|
-
host.
|
|
164
|
+
// The pen has nothing to commit: the end of a drag only lets the host say, once, what the pen is now.
|
|
165
|
+
if (editsPen) host.changePenStyle({}, { final: true });
|
|
166
|
+
else host.engine.commit();
|
|
119
167
|
}
|
|
120
168
|
|
|
121
169
|
onDestroy(() => {
|
|
@@ -165,7 +213,13 @@
|
|
|
165
213
|
}
|
|
166
214
|
|
|
167
215
|
const percent = (fraction: number): number => Math.round(fraction * 100);
|
|
168
|
-
|
|
216
|
+
// An arrow (or any shape that is only a line) cannot be given no line: the stepper stops at the thinnest one, and the mixed
|
|
217
|
+
// selection starts its buttons from there instead of from a 0 that is out of range.
|
|
218
|
+
// The pen is a line drawn by hand, whose thinnest is the brush's.
|
|
219
|
+
const strokeWidthMin = $derived(editsPen ? MIN_BRUSH_WIDTH : minimumStrokeWidth(traits));
|
|
220
|
+
const strokeWidthValue = $derived(traitNumber(traits.strokeWidth, strokeWidthMin));
|
|
221
|
+
// The pen is never made so faint that it cannot be seen (the slider goes in whole percents, see `MIN_PEN_OPACITY`).
|
|
222
|
+
const opacityMin = $derived(editsPen ? Math.round(MIN_PEN_OPACITY * 100) : 0);
|
|
169
223
|
const fontSizeValue = $derived(traits.text ? traitNumber(traits.text.fontSize, 16) : 16);
|
|
170
224
|
|
|
171
225
|
// The widget on the board is not edited here: a selected card whose widget is there has no settings control and no panel.
|
|
@@ -174,12 +228,15 @@
|
|
|
174
228
|
);
|
|
175
229
|
// A lone widget card does not open the sketch settings panel on any board (`shouldOfferSelectionPanelForTraits`); on the
|
|
176
230
|
// simple board it does not even when the page can capture (`selectionIsAWidgetWithoutSettings`).
|
|
231
|
+
// The pen has its panel on every board that has the Draw tool: it is the way to set the line before it is drawn.
|
|
177
232
|
const showPanel = $derived(
|
|
178
|
-
|
|
179
|
-
(
|
|
233
|
+
editsPen ||
|
|
234
|
+
(!selectionIsAWidgetWithoutSettings &&
|
|
235
|
+
((shouldOfferSelectionPanelForTraits(traits) && hasSelection) || (canCapture && !canConvert)))
|
|
180
236
|
);
|
|
181
237
|
const showFillColor = $derived(showFillColorRow(traits, wireframeMode));
|
|
182
|
-
|
|
238
|
+
// The pen's colour is shown in the wireframe look too: a line drawn by hand keeps its colour there.
|
|
239
|
+
const showStrokeColor = $derived(editsPen || showStrokeColorRow(traits, wireframeMode));
|
|
183
240
|
const fontSizeDisplay = $derived(traits.text ? formatFontSizeDisplay(traits.text.fontSize) : '–');
|
|
184
241
|
const panelAnchorClass = $derived(
|
|
185
242
|
`${clearance.belowTopCards ? 'top-16' : 'top-4'} ${PANEL_MAX_WIDTH_CLASSES[clearance.besideSideCard ?? 'none']}`
|
|
@@ -192,7 +249,7 @@
|
|
|
192
249
|
style:inset-inline-end={clearance.besideSideCard ? PANEL_END_BESIDE_SIDE_CARD[clearance.besideSideCard] : undefined}
|
|
193
250
|
>
|
|
194
251
|
<div class={FLOATING_CARD_CLASSES} data-canvas-selection-settings>
|
|
195
|
-
<ToolButton label={
|
|
252
|
+
<ToolButton label={openLabel} onclick={() => host.updateUi({ selectionPanelDismissed: false })}>
|
|
196
253
|
<IconSettings />
|
|
197
254
|
</ToolButton>
|
|
198
255
|
</div>
|
|
@@ -201,7 +258,7 @@
|
|
|
201
258
|
|
|
202
259
|
{#if showPanel && !ui.selectionPanelDismissed}
|
|
203
260
|
<aside
|
|
204
|
-
aria-label={
|
|
261
|
+
aria-label={panelLabel}
|
|
205
262
|
data-canvas-ui
|
|
206
263
|
data-canvas-selection-panel
|
|
207
264
|
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']}"
|
|
@@ -210,7 +267,7 @@
|
|
|
210
267
|
<header class="flex h-8 w-full shrink-0 items-center gap-2">
|
|
211
268
|
<h2 class="truncate text-body font-semibold leading-5">{title}</h2>
|
|
212
269
|
<div class="min-h-px min-w-0 flex-1" aria-hidden="true"></div>
|
|
213
|
-
{#if hasSelection}
|
|
270
|
+
{#if hasSelection || editsPen}
|
|
214
271
|
<IconButton label={$t('canvas.panel.close')} onclick={dismiss}>
|
|
215
272
|
<IconX />
|
|
216
273
|
</IconButton>
|
|
@@ -227,7 +284,8 @@
|
|
|
227
284
|
{#if showStrokeColor}
|
|
228
285
|
<div class="flex h-9 w-full items-start" data-canvas-panel-row="stroke">
|
|
229
286
|
<span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.stroke')}</span>
|
|
230
|
-
|
|
287
|
+
<!-- A pen always has a colour: "no colour" is a choice for the outline of a shape, not for the line the next stroke is drawn with. -->
|
|
288
|
+
<ColorField label={$t('canvas.panel.stroke')} value={traits.stroke} allowNone={!editsPen} onchange={(color, commit) => changeStyle({ stroke: color }, commit)} />
|
|
231
289
|
</div>
|
|
232
290
|
{/if}
|
|
233
291
|
|
|
@@ -242,7 +300,7 @@
|
|
|
242
300
|
increaseLabel={$t('canvas.panel.increase')}
|
|
243
301
|
value={traits.strokeWidth.kind === 'same' ? Number(strokeWidthValue.toFixed(1)) : null}
|
|
244
302
|
fallbackValue={strokeWidthValue}
|
|
245
|
-
min={
|
|
303
|
+
min={strokeWidthMin}
|
|
246
304
|
max={200}
|
|
247
305
|
step={1}
|
|
248
306
|
onChange={(next) => changeStyle({ strokeWidth: next })}
|
|
@@ -265,7 +323,7 @@
|
|
|
265
323
|
<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'))}>
|
|
266
324
|
<span class="flex h-9 min-w-0 flex-1 items-center gap-1 text-body">{$t('canvas.panel.opacity')}</span>
|
|
267
325
|
<div class="flex w-[185px] shrink-0 items-center gap-3">
|
|
268
|
-
<Slider type="single" min={
|
|
326
|
+
<Slider type="single" min={opacityMin} max={100} step={1} value={percent(traitNumber(traits.opacity, 1))} onValueChange={(next: number) => changeStyle({ opacity: next / 100 }, false)} onValueCommit={endChange} />
|
|
269
327
|
<span class="w-7 shrink-0 text-end text-body tabular-nums">{traits.opacity.kind === 'same' ? percent(traits.opacity.value) : '–'}</span>
|
|
270
328
|
</div>
|
|
271
329
|
</div>
|
|
@@ -359,6 +417,9 @@
|
|
|
359
417
|
</div>
|
|
360
418
|
{/if}
|
|
361
419
|
|
|
362
|
-
|
|
420
|
+
<!-- What can be done with the sketch for the page (capture, convert, rename) is about the board, not about the pen: the pen's panel is only the pen. -->
|
|
421
|
+
{#if !editsPen}
|
|
422
|
+
<WidgetActions {host} {state} {ui} {traits} {canCapture} {canConvert} {canRename} {canRefresh} {canOpenDetails} />
|
|
423
|
+
{/if}
|
|
363
424
|
</aside>
|
|
364
425
|
{/if}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Figma "Shape Menu": the button with the category icon and a chevron at the end of the toolbar's drawing group, and the menu it
|
|
3
3
|
opens: the eight shapes people reach for (a square, a rounded square, a circle, a triangle, a diamond, a hexagon, a star
|
|
4
|
-
and a pentagon), the media entries (an image
|
|
4
|
+
and a pentagon), the media entries (the person's files, when the page offers them, then an image and an SVG), and "More shapes",
|
|
5
|
+
which opens the whole library by group.
|
|
5
6
|
|
|
6
7
|
The menu is the design system's Dropdown Menu, portaled so it is not clipped by a hosting card (see floatingLayer.ts).
|
|
7
8
|
Choosing a shape does not draw it: it arms the tool,
|
|
8
9
|
and the shape is dragged out on the board, as for every tool.
|
|
10
|
+
|
|
11
|
+
Each tile has a tooltip with the shape's name and, when it has one, its key (the same tooltip as the toolbar's buttons). The keys
|
|
12
|
+
of the shapes work while the menu is open: the host answers them (see `CanvasHost`), the tool changes and the menu stays open,
|
|
13
|
+
so the mark moves to the tile of the shape as it is looked at.
|
|
9
14
|
-->
|
|
10
15
|
<script lang="ts">
|
|
11
16
|
import { DropdownMenu } from '@widgetic/design-system/components';
|
|
12
17
|
import type { ToolId } from '../../engine/state.js';
|
|
13
18
|
import { useCanvasLanguage } from '../../i18n/language.js';
|
|
14
19
|
import { categoryLabel } from '../../i18n/labels.js';
|
|
20
|
+
import { TOOL_KEYS } from '../../i18n/shortcuts.js';
|
|
15
21
|
import { getShapeByKey, getShapesByCategory } from '../shapes/ShapeLibrary.js';
|
|
16
22
|
import type { LibraryShape } from '../shapes/ShapeLibrary.js';
|
|
17
23
|
import type { CanvasHost } from '../host/CanvasHost.js';
|
|
@@ -23,16 +29,19 @@
|
|
|
23
29
|
MENU_TRIGGER_RING_CLASSES,
|
|
24
30
|
OVERLAY_REDUCED_MOTION_CLASSES,
|
|
25
31
|
SHAPE_LIBRARY_STROKE_WIDTH,
|
|
32
|
+
TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES,
|
|
26
33
|
TOOLBAR_ICON_STROKE_CLASSES
|
|
27
34
|
} from './floatingCard.js';
|
|
28
35
|
import { canvasOverlayPortalProps, useFloatingLayer } from './floatingLayer.js';
|
|
29
36
|
import { usePopoverSide } from './popoverSide.js';
|
|
37
|
+
import ShortcutTooltip from './ShortcutTooltip.svelte';
|
|
30
38
|
import {
|
|
31
39
|
IconBrowser,
|
|
32
40
|
IconCategory,
|
|
33
41
|
IconChevronDown,
|
|
34
42
|
IconCircle,
|
|
35
43
|
IconDiamond,
|
|
44
|
+
IconFolder,
|
|
36
45
|
IconHexagon,
|
|
37
46
|
IconPentagon,
|
|
38
47
|
IconPhoto,
|
|
@@ -51,9 +60,11 @@
|
|
|
51
60
|
open: boolean;
|
|
52
61
|
/** The key that opens the image chooser, as it is printed on a key cap. */
|
|
53
62
|
imageShortcut: string;
|
|
63
|
+
/** Whether the menu offers the person's file library before the Image entry (the page turned it on and gave the browser that opens it). */
|
|
64
|
+
showFiles?: boolean;
|
|
54
65
|
}
|
|
55
66
|
|
|
56
|
-
let { host, tool, libraryShapeKey, open, imageShortcut }: Props = $props();
|
|
67
|
+
let { host, tool, libraryShapeKey, open, imageShortcut, showFiles = false }: Props = $props();
|
|
57
68
|
|
|
58
69
|
// The menu is drawn into the canvas's floating layer (see floatingLayer.ts).
|
|
59
70
|
const floatingLayer = useFloatingLayer();
|
|
@@ -66,20 +77,24 @@
|
|
|
66
77
|
|
|
67
78
|
const { t } = useCanvasLanguage();
|
|
68
79
|
|
|
69
|
-
/** A tile of the first two rows: what it draws, how it is named, and when it is the one in use. */
|
|
80
|
+
/** A tile of the first two rows: what it draws, how it is named, the key that chooses it (if it has one), and when it is the one in use. */
|
|
70
81
|
interface Tile {
|
|
71
82
|
id: string;
|
|
72
83
|
icon: CanvasIcon;
|
|
73
84
|
label: CanvasMessageKey;
|
|
85
|
+
/** The key that chooses the shape, as it is printed on a key cap: in the tile's tooltip, and its `aria-keyshortcuts`. */
|
|
86
|
+
shortcut?: string;
|
|
74
87
|
active: boolean;
|
|
75
88
|
choose: () => void;
|
|
76
89
|
}
|
|
77
90
|
|
|
78
91
|
const tiles = $derived<Tile[]>([
|
|
79
|
-
{ id: 'rect', icon: IconSquare, label: 'canvas.tool.rectangle', active: tool === 'rect', choose: () => host.onSelectShapeTool('rect') },
|
|
92
|
+
{ id: 'rect', icon: IconSquare, label: 'canvas.tool.rectangle', shortcut: TOOL_KEYS.rectangle, active: tool === 'rect', choose: () => host.onSelectShapeTool('rect') },
|
|
80
93
|
{ id: 'rounded-rect', icon: IconSquareRounded, label: 'canvas.tool.roundedRectangle', active: tool === 'rounded-rect', choose: () => host.onSelectShapeTool('rounded-rect') },
|
|
81
|
-
|
|
82
|
-
|
|
94
|
+
// The round shape of the menu: its key (O) draws the oval, which the menu has no tile of its own for, so the circle's tile is the one
|
|
95
|
+
// that is marked (and that names the key) whether the tool in use is the circle or the oval.
|
|
96
|
+
{ id: 'circle', icon: IconCircle, label: 'canvas.tool.circle', shortcut: TOOL_KEYS.ellipse, active: tool === 'circle' || tool === 'ellipse', choose: () => host.onSelectShapeTool('circle-true') },
|
|
97
|
+
{ id: 'triangle', icon: IconTriangle, label: 'canvas.tool.triangle', shortcut: TOOL_KEYS.triangle, active: tool === 'triangle', choose: () => host.onSelectShapeTool('triangle') },
|
|
83
98
|
libraryTile('diamond', IconDiamond),
|
|
84
99
|
libraryTile('hexagon', IconHexagon),
|
|
85
100
|
libraryTile('star', IconStar),
|
|
@@ -117,7 +132,7 @@
|
|
|
117
132
|
type="button"
|
|
118
133
|
aria-label={$t('canvas.tool.shapes')}
|
|
119
134
|
data-active={shapeToolInUse ? '' : undefined}
|
|
120
|
-
class="flex h-9 w-[51px] shrink-0 items-center justify-center gap-1 rounded-lg text-foreground transition-colors duration-fast hover:bg-accent focus-visible:outline-hidden data-[active]:bg-brand-subtle {MENU_TRIGGER_RING_CLASSES} [&_svg]:size-4 {TOOLBAR_ICON_STROKE_CLASSES}"
|
|
135
|
+
class="flex h-9 w-[51px] shrink-0 items-center justify-center gap-1 rounded-lg text-foreground transition-colors duration-fast hover:bg-accent focus-visible:bg-accent focus-visible:outline-hidden data-[active]:bg-brand-subtle {TOOLBAR_ACTIVE_FOCUS_TINT_CLASSES} {MENU_TRIGGER_RING_CLASSES} [&_svg]:size-4 {TOOLBAR_ICON_STROKE_CLASSES}"
|
|
121
136
|
>
|
|
122
137
|
<IconCategory />
|
|
123
138
|
<IconChevronDown class="transition-transform duration-fast motion-reduce:transition-none data-[open]:rotate-180" data-open={open ? '' : undefined} />
|
|
@@ -125,25 +140,39 @@
|
|
|
125
140
|
{/snippet}
|
|
126
141
|
</DropdownMenu.Trigger>
|
|
127
142
|
|
|
128
|
-
|
|
143
|
+
<!-- `data-canvas-ui`: the menu (its "More shapes" submenu sits inside it) is the canvas's own even when it is portaled to `document.body` (a page without a shadow root), so a press on a tile is not a press outside the canvas (`outsideClickDeselect.ts`). -->
|
|
144
|
+
<DropdownMenu.Content side={menuSide} align={menuAlign} sideOffset={8} portalProps={canvasOverlayPortalProps($floatingLayer)} aria-label={$t('canvas.tool.shapes')} data-canvas-ui class="{CANVAS_OVERLAY_Z_CLASS} w-[196px] {MENU_PADDING_CLASS} shadow-floating focus-visible:outline-hidden {OVERLAY_REDUCED_MOTION_CLASSES}">
|
|
129
145
|
<DropdownMenu.Label>{$t('canvas.tool.shapes')}</DropdownMenu.Label>
|
|
130
146
|
<div class="grid grid-cols-4 gap-x-3 px-1" role="presentation">
|
|
131
147
|
{#each tiles as tile (tile.id)}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
<!-- The pointer gives a menu entry the focus as it passes, so only a focus from the keyboard opens the tooltip at once. -->
|
|
149
|
+
<ShortcutTooltip label={$t(tile.label)} shortcut={tile.shortcut} side="top" ignoreNonKeyboardFocus passive>
|
|
150
|
+
{#snippet trigger(triggerProps)}
|
|
151
|
+
<DropdownMenu.Item
|
|
152
|
+
{...triggerProps}
|
|
153
|
+
aria-label={$t(tile.label)}
|
|
154
|
+
aria-keyshortcuts={tile.shortcut}
|
|
155
|
+
aria-current={tile.active ? 'true' : undefined}
|
|
156
|
+
data-active={tile.active ? '' : undefined}
|
|
157
|
+
class="size-9 min-h-9 justify-center p-0 data-[active]:bg-brand-subtle {TOOLBAR_ICON_STROKE_CLASSES}"
|
|
158
|
+
onSelect={tile.choose}
|
|
159
|
+
>
|
|
160
|
+
<tile.icon class="size-4" />
|
|
161
|
+
</DropdownMenu.Item>
|
|
162
|
+
{/snippet}
|
|
163
|
+
</ShortcutTooltip>
|
|
142
164
|
{/each}
|
|
143
165
|
</div>
|
|
144
166
|
|
|
145
167
|
<DropdownMenu.Separator />
|
|
146
168
|
<DropdownMenu.Label>{$t('canvas.menu.media')}</DropdownMenu.Label>
|
|
169
|
+
<!-- The person's file library (the page's File Browser, in select state). Only when the page turned it on: it is off by default. -->
|
|
170
|
+
{#if showFiles}
|
|
171
|
+
<DropdownMenu.Item data-canvas-files-entry onSelect={() => void host.openFileBrowser()}>
|
|
172
|
+
<IconFolder />
|
|
173
|
+
<span class="flex-1">{$t('canvas.tool.files')}</span>
|
|
174
|
+
</DropdownMenu.Item>
|
|
175
|
+
{/if}
|
|
147
176
|
<DropdownMenu.Item aria-keyshortcuts={imageShortcut} onSelect={() => void host.addImage()}>
|
|
148
177
|
<IconPhoto />
|
|
149
178
|
<span class="flex-1">{$t('canvas.tool.image')}</span>
|
|
@@ -161,19 +190,24 @@
|
|
|
161
190
|
<DropdownMenu.Label>{categoryLabel(category, $t)}</DropdownMenu.Label>
|
|
162
191
|
<div class="grid grid-cols-5 gap-1 px-1 pb-1" role="presentation">
|
|
163
192
|
{#each shapes as shape (shape.key)}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
193
|
+
<!-- The shapes of the library have no key: their tooltip is the name alone. -->
|
|
194
|
+
<ShortcutTooltip label={$t(shape.labelKey)} side="top" ignoreNonKeyboardFocus passive>
|
|
195
|
+
{#snippet trigger(triggerProps)}
|
|
196
|
+
<DropdownMenu.Item
|
|
197
|
+
{...triggerProps}
|
|
198
|
+
aria-label={$t(shape.labelKey)}
|
|
199
|
+
aria-current={tool === 'library-shape' && libraryShapeKey === shape.key ? 'true' : undefined}
|
|
200
|
+
data-active={tool === 'library-shape' && libraryShapeKey === shape.key ? '' : undefined}
|
|
201
|
+
class="size-9 min-h-9 justify-center p-0 data-[active]:bg-brand-subtle"
|
|
202
|
+
onSelect={() => host.onSelectLibraryShapeTool(shape.key)}
|
|
203
|
+
>
|
|
204
|
+
<!-- The width is an inline style on purpose: the menu item's `[&_svg]:stroke-2` would beat the attribute (see floatingCard.ts). -->
|
|
205
|
+
<svg viewBox="0 0 100 100" class="size-4" fill="none" stroke="currentColor" style:stroke-width={SHAPE_LIBRARY_STROKE_WIDTH} stroke-linejoin="round" stroke-linecap="round" aria-hidden="true">
|
|
206
|
+
<path d={shape.pathData} />
|
|
207
|
+
</svg>
|
|
208
|
+
</DropdownMenu.Item>
|
|
209
|
+
{/snippet}
|
|
210
|
+
</ShortcutTooltip>
|
|
177
211
|
{/each}
|
|
178
212
|
</div>
|
|
179
213
|
{/each}
|
|
@@ -9,6 +9,8 @@ interface Props {
|
|
|
9
9
|
open: boolean;
|
|
10
10
|
/** The key that opens the image chooser, as it is printed on a key cap. */
|
|
11
11
|
imageShortcut: string;
|
|
12
|
+
/** Whether the menu offers the person's file library before the Image entry (the page turned it on and gave the browser that opens it). */
|
|
13
|
+
showFiles?: boolean;
|
|
12
14
|
}
|
|
13
15
|
declare const ShapesMenu: import("svelte").Component<Props, {}, "">;
|
|
14
16
|
type ShapesMenu = ReturnType<typeof ShapesMenu>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
The tooltip of a control of the chrome: its name and, when it has one, the key that does the same, on a key cap (Figma "Tool
|
|
3
|
+
Button" tooltip). The toolbar's buttons and the tiles of the Shapes menu draw it, so the two look and behave alike.
|
|
4
|
+
|
|
5
|
+
The control is whatever the caller draws, handed in as the `trigger` snippet: it is given the props of the tooltip's trigger to
|
|
6
|
+
spread onto its element (an Icon Button, a plain button, an entry of a menu). The tooltip is drawn into the canvas's floating
|
|
7
|
+
layer, not in place (see floatingLayer.ts), and it opens after the delay the canvas's provider gives it (`CANVAS_TOOLTIP_DELAY_MS`,
|
|
8
|
+
set in DomCanvas.svelte).
|
|
9
|
+
-->
|
|
10
|
+
<script lang="ts">
|
|
11
|
+
import type { Snippet } from 'svelte';
|
|
12
|
+
import { Tooltip } from '@widgetic/design-system/components';
|
|
13
|
+
import { CANVAS_OVERLAY_Z_CLASS, OVERLAY_REDUCED_MOTION_CLASSES } from './floatingCard.js';
|
|
14
|
+
import { canvasOverlayPortalProps, useFloatingLayer } from './floatingLayer.js';
|
|
15
|
+
import { usePopoverSide } from './popoverSide.js';
|
|
16
|
+
|
|
17
|
+
interface Props {
|
|
18
|
+
/** What the control does: the first line of the tooltip. */
|
|
19
|
+
label: string;
|
|
20
|
+
/** The key that does the same, as it is printed on a key cap ("V"), or nothing: the tooltip is then the name alone. */
|
|
21
|
+
shortcut?: string | undefined;
|
|
22
|
+
/** The side the tooltip opens on. Left out: away from the edge the toolbar stands against (see popoverSide.ts). */
|
|
23
|
+
side?: 'top' | 'right' | 'bottom' | 'left' | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* For a control the pointer gives the focus to by itself (the entries of a menu take the focus as the pointer passes over
|
|
26
|
+
* them): only a focus that comes from the keyboard opens the tooltip at once, and the pointer opens it after its delay.
|
|
27
|
+
*/
|
|
28
|
+
ignoreNonKeyboardFocus?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The tooltip closes as soon as the pointer leaves the control and cannot be hovered itself, so it never stands between the
|
|
31
|
+
* pointer and the controls it overlaps (the tiles of a menu lie close together).
|
|
32
|
+
*/
|
|
33
|
+
passive?: boolean;
|
|
34
|
+
/** The control. It is given the props of the tooltip's trigger, to spread onto its element. */
|
|
35
|
+
trigger: Snippet<[Record<string, unknown>]>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let { label, shortcut = undefined, side = undefined, ignoreNonKeyboardFocus = false, passive = false, trigger }: Props = $props();
|
|
39
|
+
|
|
40
|
+
// The tooltip is drawn into the canvas's floating layer, not in place: see floatingLayer.ts.
|
|
41
|
+
const floatingLayer = useFloatingLayer();
|
|
42
|
+
// Until the canvas has made its layer nothing is mounted (the tooltip is closed then anyway), so the page's body is not written to.
|
|
43
|
+
const overlayPortal = $derived(canvasOverlayPortalProps($floatingLayer));
|
|
44
|
+
// It opens away from the edge the card stands on: upward from the bottom, downward from the top, sideways from a side.
|
|
45
|
+
const popoverSide = usePopoverSide();
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<Tooltip.Root {ignoreNonKeyboardFocus} disableHoverableContent={passive}>
|
|
49
|
+
<Tooltip.Trigger>
|
|
50
|
+
{#snippet child({ props }: { props: Record<string, unknown> })}
|
|
51
|
+
{@render trigger(props)}
|
|
52
|
+
{/snippet}
|
|
53
|
+
</Tooltip.Trigger>
|
|
54
|
+
<Tooltip.Portal to={overlayPortal.to} disabled={overlayPortal.disabled}>
|
|
55
|
+
<Tooltip.Content side={side ?? popoverSide()} sideOffset={passive ? 6 : 8} class="{CANVAS_OVERLAY_Z_CLASS} {OVERLAY_REDUCED_MOTION_CLASSES} {passive ? 'pointer-events-none' : ''}">
|
|
56
|
+
<span class="flex items-center gap-2">
|
|
57
|
+
<span>{label}</span>
|
|
58
|
+
{#if shortcut}
|
|
59
|
+
<kbd class="rounded-sm bg-muted px-1.5 py-0.5 font-sans text-xs text-muted-foreground">{shortcut}</kbd>
|
|
60
|
+
{/if}
|
|
61
|
+
</span>
|
|
62
|
+
</Tooltip.Content>
|
|
63
|
+
</Tooltip.Portal>
|
|
64
|
+
</Tooltip.Root>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface Props {
|
|
3
|
+
/** What the control does: the first line of the tooltip. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** The key that does the same, as it is printed on a key cap ("V"), or nothing: the tooltip is then the name alone. */
|
|
6
|
+
shortcut?: string | undefined;
|
|
7
|
+
/** The side the tooltip opens on. Left out: away from the edge the toolbar stands against (see popoverSide.ts). */
|
|
8
|
+
side?: 'top' | 'right' | 'bottom' | 'left' | undefined;
|
|
9
|
+
/**
|
|
10
|
+
* For a control the pointer gives the focus to by itself (the entries of a menu take the focus as the pointer passes over
|
|
11
|
+
* them): only a focus that comes from the keyboard opens the tooltip at once, and the pointer opens it after its delay.
|
|
12
|
+
*/
|
|
13
|
+
ignoreNonKeyboardFocus?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* The tooltip closes as soon as the pointer leaves the control and cannot be hovered itself, so it never stands between the
|
|
16
|
+
* pointer and the controls it overlaps (the tiles of a menu lie close together).
|
|
17
|
+
*/
|
|
18
|
+
passive?: boolean;
|
|
19
|
+
/** The control. It is given the props of the tooltip's trigger, to spread onto its element. */
|
|
20
|
+
trigger: Snippet<[Record<string, unknown>]>;
|
|
21
|
+
}
|
|
22
|
+
declare const ShortcutTooltip: import("svelte").Component<Props, {}, "">;
|
|
23
|
+
type ShortcutTooltip = ReturnType<typeof ShortcutTooltip>;
|
|
24
|
+
export default ShortcutTooltip;
|