@netless/fastboard-ui 0.3.2-canary.2 → 0.3.2-canary.5
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/LICENSE.txt +21 -21
- package/README.md +7 -7
- package/dist/index.d.ts +103 -74
- package/dist/index.js +850 -410
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +850 -410
- package/dist/index.mjs.map +1 -1
- package/dist/index.svelte.mjs +1237 -777
- package/dist/index.svelte.mjs.map +1 -1
- package/package.json +4 -4
- package/src/actions/height.ts +43 -43
- package/src/actions/scroll.ts +31 -31
- package/src/actions/tippy.ts +71 -71
- package/src/behaviors/apps.ts +74 -70
- package/src/behaviors/index.ts +1 -1
- package/src/components/Button/Button.svelte +51 -51
- package/src/components/Button/Button.svelte.d.ts +26 -26
- package/src/components/Button/index.ts +2 -2
- package/src/components/Fastboard/Fastboard.scss +61 -61
- package/src/components/Fastboard/Fastboard.svelte +80 -71
- package/src/components/Fastboard/Fastboard.svelte.ts +14 -13
- package/src/components/Fastboard/ReplayFastboard.svelte +43 -43
- package/src/components/Fastboard/ReplayFastboard.svelte.ts +13 -13
- package/src/components/Fastboard/index.ts +5 -5
- package/src/components/Icon/Icon.svelte +11 -11
- package/src/components/Icon/Icon.svelte.d.ts +10 -10
- package/src/components/Icon/index.ts +2 -2
- package/src/components/Icons/Apps.svelte +49 -49
- package/src/components/Icons/Arrow.svelte +16 -16
- package/src/components/Icons/ArrowBolded.svelte +17 -17
- package/src/components/Icons/Balloon.svelte +16 -16
- package/src/components/Icons/BalloonBolded.svelte +16 -16
- package/src/components/Icons/Circle.svelte +20 -20
- package/src/components/Icons/CircleBolded.svelte +20 -20
- package/src/components/Icons/Clean.svelte +14 -14
- package/src/components/Icons/Clear.svelte +16 -16
- package/src/components/Icons/Click.svelte +16 -16
- package/src/components/Icons/ClickFilled.svelte +10 -10
- package/src/components/Icons/Diamond.svelte +16 -16
- package/src/components/Icons/Down.svelte +16 -16
- package/src/components/Icons/Eraser.svelte +16 -16
- package/src/components/Icons/EraserFilled.svelte +16 -16
- package/src/components/Icons/Icons.scss +20 -20
- package/src/components/Icons/Left.svelte +16 -16
- package/src/components/Icons/Line.svelte +16 -16
- package/src/components/Icons/LineBolded.svelte +16 -16
- package/src/components/Icons/Loading.svelte +10 -10
- package/src/components/Icons/Minus.svelte +16 -16
- package/src/components/Icons/Pause.svelte +10 -10
- package/src/components/Icons/Pencil.svelte +29 -29
- package/src/components/Icons/PencilFilled.svelte +16 -16
- package/src/components/Icons/Play.svelte +10 -10
- package/src/components/Icons/Plus.svelte +16 -16
- package/src/components/Icons/Rectangle.svelte +16 -16
- package/src/components/Icons/RectangleBolded.svelte +16 -16
- package/src/components/Icons/Redo.svelte +15 -15
- package/src/components/Icons/Reset.svelte +26 -26
- package/src/components/Icons/Rhombus.svelte +16 -16
- package/src/components/Icons/RhombusBolded.svelte +16 -16
- package/src/components/Icons/Right.svelte +16 -16
- package/src/components/Icons/Selector.svelte +24 -24
- package/src/components/Icons/SelectorFilled.svelte +18 -18
- package/src/components/Icons/SpeechBalloon.svelte +16 -16
- package/src/components/Icons/Star.svelte +16 -16
- package/src/components/Icons/StarBolded.svelte +16 -16
- package/src/components/Icons/Text.svelte +16 -16
- package/src/components/Icons/TextFilled.svelte +17 -17
- package/src/components/Icons/Triangle.svelte +16 -16
- package/src/components/Icons/TriangleBolded.svelte +16 -16
- package/src/components/Icons/Undo.svelte +15 -15
- package/src/components/Icons/Up.svelte +16 -16
- package/src/components/Icons/WhiteboardAdd.svelte +34 -34
- package/src/components/Icons/index.ts +93 -93
- package/src/components/PageControl/PageControl.scss +15 -15
- package/src/components/PageControl/PageControl.svelte +79 -79
- package/src/components/PageControl/PageControl.svelte.d.ts +13 -13
- package/src/components/PageControl/index.ts +2 -2
- package/src/components/PlayerControl/PlayerControl.scss +57 -57
- package/src/components/PlayerControl/PlayerControl.svelte +153 -153
- package/src/components/PlayerControl/PlayerControl.svelte.d.ts +13 -13
- package/src/components/PlayerControl/index.ts +2 -2
- package/src/components/RedoUndo/RedoUndo.scss +11 -11
- package/src/components/RedoUndo/RedoUndo.svelte +60 -60
- package/src/components/RedoUndo/RedoUndo.svelte.d.ts +13 -13
- package/src/components/RedoUndo/index.ts +2 -2
- package/src/components/Toolbar/README.md +57 -57
- package/src/components/Toolbar/Toolbar.scss +78 -78
- package/src/components/Toolbar/Toolbar.svelte +62 -50
- package/src/components/Toolbar/Toolbar.svelte.d.ts +13 -12
- package/src/components/Toolbar/components/Contents.scss +168 -168
- package/src/components/Toolbar/components/Contents.svelte +197 -193
- package/src/components/Toolbar/components/Shapes.svelte +85 -85
- package/src/components/Toolbar/components/Slider.scss +119 -119
- package/src/components/Toolbar/components/Slider.svelte +54 -54
- package/src/components/Toolbar/components/StrokeColor.svelte +39 -39
- package/src/components/Toolbar/components/StrokeWidth.svelte +20 -20
- package/src/components/Toolbar/components/TextColor.svelte +39 -0
- package/src/components/Toolbar/components/constants.ts +80 -80
- package/src/components/Toolbar/components/helper.ts +24 -24
- package/src/components/Toolbar/index.ts +2 -2
- package/src/components/ZoomControl/ZoomControl.scss +15 -15
- package/src/components/ZoomControl/ZoomControl.svelte +99 -99
- package/src/components/ZoomControl/ZoomControl.svelte.d.ts +13 -13
- package/src/components/ZoomControl/index.ts +2 -2
- package/src/components/helpers.ts +3 -3
- package/src/components/theme.scss +92 -92
- package/src/components/variables.scss +69 -69
- package/src/index.ts +13 -13
- package/src/style.scss +36 -36
- package/src/typings.ts +38 -17
|
@@ -1,193 +1,197 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Appliance, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
-
import type { Writable } from "svelte/store";
|
|
4
|
-
import type { Placement } from "tippy.js";
|
|
5
|
-
import type { Language, Theme } from "../../../typings";
|
|
6
|
-
import type { Shape } from "./constants";
|
|
7
|
-
import { applianceShapes, shapesIcon, shapesIconActive } from "./constants";
|
|
8
|
-
import { writable } from "svelte/store";
|
|
9
|
-
import { scrollHeight } from "../../../actions/height";
|
|
10
|
-
import { scrollTop } from "../../../actions/scroll";
|
|
11
|
-
import { clamp } from "../../helpers";
|
|
12
|
-
import { i18n } from "./constants";
|
|
13
|
-
import { apps } from "../../../behaviors";
|
|
14
|
-
import { tooltip } from "./helper";
|
|
15
|
-
import Icons from "../../Icons";
|
|
16
|
-
import Button from "../../Button";
|
|
17
|
-
import StrokeWidth from "./StrokeWidth.svelte";
|
|
18
|
-
import StrokeColor from "./StrokeColor.svelte";
|
|
19
|
-
import
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export let
|
|
23
|
-
export let
|
|
24
|
-
export let
|
|
25
|
-
export let
|
|
26
|
-
export let
|
|
27
|
-
export let
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
let
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
$:
|
|
42
|
-
$:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
$:
|
|
52
|
-
$:
|
|
53
|
-
|
|
54
|
-
$:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
last_shape =
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
app?.setAppliance(
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
{
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
{
|
|
108
|
-
<Icons.
|
|
109
|
-
{
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{
|
|
115
|
-
<Icons.
|
|
116
|
-
{
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
{
|
|
122
|
-
<Icons.
|
|
123
|
-
{
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
{
|
|
129
|
-
<Icons.
|
|
130
|
-
{
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
{
|
|
136
|
-
<svelte:component this={
|
|
137
|
-
{
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
<Icons.
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
{
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
{
|
|
158
|
-
|
|
159
|
-
<
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
<
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
<
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
{
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
</
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Appliance, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Writable } from "svelte/store";
|
|
4
|
+
import type { Placement } from "tippy.js";
|
|
5
|
+
import type { Language, Theme } from "../../../typings";
|
|
6
|
+
import type { Shape } from "./constants";
|
|
7
|
+
import { applianceShapes, shapesIcon, shapesIconActive } from "./constants";
|
|
8
|
+
import { writable } from "svelte/store";
|
|
9
|
+
import { scrollHeight } from "../../../actions/height";
|
|
10
|
+
import { scrollTop } from "../../../actions/scroll";
|
|
11
|
+
import { clamp } from "../../helpers";
|
|
12
|
+
import { i18n } from "./constants";
|
|
13
|
+
import { apps } from "../../../behaviors";
|
|
14
|
+
import { tooltip } from "./helper";
|
|
15
|
+
import Icons from "../../Icons";
|
|
16
|
+
import Button from "../../Button";
|
|
17
|
+
import StrokeWidth from "./StrokeWidth.svelte";
|
|
18
|
+
import StrokeColor from "./StrokeColor.svelte";
|
|
19
|
+
import TextColor from "./TextColor.svelte";
|
|
20
|
+
import Shapes from "./Shapes.svelte";
|
|
21
|
+
|
|
22
|
+
export let app: FastboardApp | null | undefined = null;
|
|
23
|
+
export let theme: Theme = "light";
|
|
24
|
+
export let language: Language = "en";
|
|
25
|
+
export let disabled = false;
|
|
26
|
+
export let scroll_height: Writable<number>;
|
|
27
|
+
export let computed_height = 0;
|
|
28
|
+
export let scrollable = false;
|
|
29
|
+
export let hide_apps = false;
|
|
30
|
+
|
|
31
|
+
const name = "fastboard-toolbar";
|
|
32
|
+
|
|
33
|
+
let last_shape: Shape = "rectangle";
|
|
34
|
+
|
|
35
|
+
let pencil_panel: HTMLDivElement;
|
|
36
|
+
let text_panel: HTMLDivElement;
|
|
37
|
+
let shapes_panel: HTMLDivElement;
|
|
38
|
+
let apps_panel: HTMLDivElement;
|
|
39
|
+
|
|
40
|
+
let btn_props: { name: string; theme: Theme; disabled: boolean; placement: Placement };
|
|
41
|
+
$: btn_props = { name, theme, disabled, placement: "right" };
|
|
42
|
+
$: t = i18n[language];
|
|
43
|
+
$: hotkeys = app?.hotKeys;
|
|
44
|
+
$: c = {
|
|
45
|
+
clicker: tooltip(t.clicker, hotkeys?.changeToClick),
|
|
46
|
+
selector: tooltip(t.selector, hotkeys?.changeToSelector),
|
|
47
|
+
pencil: tooltip(t.pencil, hotkeys?.changeToPencil),
|
|
48
|
+
eraser: tooltip(t.eraser, hotkeys?.changeToEraser),
|
|
49
|
+
text: tooltip(t.text, hotkeys?.changeToText),
|
|
50
|
+
};
|
|
51
|
+
$: memberState = app?.memberState;
|
|
52
|
+
$: appliance = $memberState?.currentApplianceName;
|
|
53
|
+
$: shape = $memberState?.shapeType;
|
|
54
|
+
$: status = app?.appsStatus;
|
|
55
|
+
|
|
56
|
+
$: if (applianceShapes.includes(appliance as Appliance)) {
|
|
57
|
+
last_shape = appliance as Shape;
|
|
58
|
+
} else if (shape) {
|
|
59
|
+
last_shape = shape;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
$: max_scroll = scrollable ? $scroll_height + (32 + 8) * 2 - computed_height : 0;
|
|
63
|
+
|
|
64
|
+
let top = writable(0);
|
|
65
|
+
|
|
66
|
+
function scroll_up() {
|
|
67
|
+
$top = clamp($top - 32 - 4, 0, max_scroll);
|
|
68
|
+
}
|
|
69
|
+
function scroll_down() {
|
|
70
|
+
$top = clamp($top + 32 + 4, 0, max_scroll);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function clicker() {
|
|
74
|
+
app?.setAppliance("clicker");
|
|
75
|
+
}
|
|
76
|
+
function selector() {
|
|
77
|
+
app?.setAppliance("selector");
|
|
78
|
+
}
|
|
79
|
+
function pencil() {
|
|
80
|
+
app?.setAppliance("pencil");
|
|
81
|
+
}
|
|
82
|
+
function text() {
|
|
83
|
+
app?.setAppliance("text");
|
|
84
|
+
}
|
|
85
|
+
function select_last_shape() {
|
|
86
|
+
if (applianceShapes.includes(last_shape as Appliance)) {
|
|
87
|
+
app?.setAppliance(last_shape as Appliance);
|
|
88
|
+
} else {
|
|
89
|
+
app?.setAppliance("shape", last_shape as Exclude<Shape, Appliance>);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function eraser() {
|
|
93
|
+
app?.setAppliance("eraser");
|
|
94
|
+
}
|
|
95
|
+
function clear() {
|
|
96
|
+
app?.cleanCurrentScene();
|
|
97
|
+
}
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
{#if scrollable}
|
|
101
|
+
<Button class="scroll-up" {...btn_props} on:click={scroll_up}>
|
|
102
|
+
<Icons.Up {theme} />
|
|
103
|
+
</Button>
|
|
104
|
+
{/if}
|
|
105
|
+
<div class="{name}-scrollable" class:scrollable use:scrollHeight={scroll_height} use:scrollTop={top}>
|
|
106
|
+
<Button class="clicker" {...btn_props} on:click={clicker} content={c.clicker}>
|
|
107
|
+
{#if appliance === "clicker"}
|
|
108
|
+
<Icons.ClickFilled {theme} active />
|
|
109
|
+
{:else}
|
|
110
|
+
<Icons.Click {theme} />
|
|
111
|
+
{/if}
|
|
112
|
+
</Button>
|
|
113
|
+
<Button class="selector" {...btn_props} on:click={selector} content={c.selector}>
|
|
114
|
+
{#if appliance === "selector"}
|
|
115
|
+
<Icons.SelectorFilled {theme} active />
|
|
116
|
+
{:else}
|
|
117
|
+
<Icons.Selector {theme} />
|
|
118
|
+
{/if}
|
|
119
|
+
</Button>
|
|
120
|
+
<Button class="pencil" {...btn_props} on:click={pencil} content={c.pencil} menu={pencil_panel}>
|
|
121
|
+
{#if appliance === "pencil"}
|
|
122
|
+
<Icons.PencilFilled {theme} active />
|
|
123
|
+
{:else}
|
|
124
|
+
<Icons.Pencil {theme} />
|
|
125
|
+
{/if}
|
|
126
|
+
</Button>
|
|
127
|
+
<Button class="text" {...btn_props} on:click={text} content={c.text} menu={text_panel}>
|
|
128
|
+
{#if appliance === "text"}
|
|
129
|
+
<Icons.TextFilled {theme} active />
|
|
130
|
+
{:else}
|
|
131
|
+
<Icons.Text {theme} />
|
|
132
|
+
{/if}
|
|
133
|
+
</Button>
|
|
134
|
+
<Button class="shapes" {...btn_props} on:click={select_last_shape} content={t.shapes} menu={shapes_panel}>
|
|
135
|
+
{#if appliance === last_shape || (appliance === "shape" && shape === last_shape)}
|
|
136
|
+
<svelte:component this={shapesIconActive[last_shape]} {theme} active />
|
|
137
|
+
{:else}
|
|
138
|
+
<svelte:component this={shapesIcon[last_shape]} {theme} />
|
|
139
|
+
{/if}
|
|
140
|
+
</Button>
|
|
141
|
+
<Button class="eraser" {...btn_props} on:click={eraser} content={c.eraser}>
|
|
142
|
+
{#if appliance === "eraser"}
|
|
143
|
+
<Icons.EraserFilled {theme} active />
|
|
144
|
+
{:else}
|
|
145
|
+
<Icons.Eraser {theme} />
|
|
146
|
+
{/if}
|
|
147
|
+
</Button>
|
|
148
|
+
<Button class="clear" {...btn_props} on:click={clear} content={t.clear}>
|
|
149
|
+
<Icons.Clear {theme} />
|
|
150
|
+
</Button>
|
|
151
|
+
{#if !hide_apps}
|
|
152
|
+
<Button class="apps" {...btn_props} content={t.apps} menu={apps_panel} menu_placement="right-end">
|
|
153
|
+
<Icons.Apps {theme} />
|
|
154
|
+
</Button>
|
|
155
|
+
{/if}
|
|
156
|
+
</div>
|
|
157
|
+
{#if scrollable}
|
|
158
|
+
<Button class="scroll-down" {name} {theme} {disabled} on:click={scroll_down}>
|
|
159
|
+
<Icons.Down {theme} />
|
|
160
|
+
</Button>
|
|
161
|
+
{/if}
|
|
162
|
+
|
|
163
|
+
<div class="{name}-panel-wrapper" style="display:none">
|
|
164
|
+
<div class="{name}-panel pencil" bind:this={pencil_panel}>
|
|
165
|
+
<StrokeWidth {app} {theme} {disabled} />
|
|
166
|
+
<div class="{name}-panel-divider" />
|
|
167
|
+
<StrokeColor {app} {theme} {disabled} />
|
|
168
|
+
</div>
|
|
169
|
+
<div class="{name}-panel text" bind:this={text_panel}>
|
|
170
|
+
<TextColor {app} {theme} {disabled} />
|
|
171
|
+
</div>
|
|
172
|
+
<div class="{name}-panel shapes" bind:this={shapes_panel}>
|
|
173
|
+
<Shapes {app} {theme} {language} {disabled} />
|
|
174
|
+
<div class="{name}-panel-divider" />
|
|
175
|
+
<StrokeWidth {app} {theme} {disabled} />
|
|
176
|
+
<div class="{name}-panel-divider" />
|
|
177
|
+
<StrokeColor {app} {theme} {disabled} />
|
|
178
|
+
</div>
|
|
179
|
+
<div class="{name}-panel apps" style="--n:{$apps.length}" bind:this={apps_panel}>
|
|
180
|
+
{#each $apps as netless_app}
|
|
181
|
+
{@const { icon, label, kind, onClick } = netless_app}
|
|
182
|
+
{@const state = $status && $status[kind]}
|
|
183
|
+
<button
|
|
184
|
+
class="{name}-app-btn {kind} {theme}"
|
|
185
|
+
class:is-loading={state && state.status === "loading"}
|
|
186
|
+
class:is-failed={state && state.status === "failed"}
|
|
187
|
+
title={label + (state && state.reason ? ": " + state.reason : "")}
|
|
188
|
+
data-app-kind={netless_app.kind}
|
|
189
|
+
disabled={state && state.status !== "idle"}
|
|
190
|
+
on:click={app && onClick.bind(null, app)}
|
|
191
|
+
>
|
|
192
|
+
<img class="{name}-app-btn-icon {theme}" src={icon} alt={kind} title={label} />
|
|
193
|
+
<span class="{name}-app-btn-text {theme}">{label}</span>
|
|
194
|
+
</button>
|
|
195
|
+
{/each}
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
<script lang="ts" context="module">
|
|
2
|
-
import type { I18nData, Language, Theme } from "../../../typings";
|
|
3
|
-
import type { Shape } from "./constants";
|
|
4
|
-
|
|
5
|
-
const i18n: I18nData<Shape> = {
|
|
6
|
-
en: {
|
|
7
|
-
rectangle: "Rectangle",
|
|
8
|
-
ellipse: "Ellipse",
|
|
9
|
-
straight: "Line",
|
|
10
|
-
arrow: "Arrow",
|
|
11
|
-
pentagram: "Star",
|
|
12
|
-
rhombus: "Diamond",
|
|
13
|
-
triangle: "Triangle",
|
|
14
|
-
speechBalloon: "Balloon",
|
|
15
|
-
},
|
|
16
|
-
"zh-CN": {
|
|
17
|
-
rectangle: "矩形",
|
|
18
|
-
ellipse: "椭圆",
|
|
19
|
-
straight: "直线",
|
|
20
|
-
arrow: "箭头",
|
|
21
|
-
pentagram: "五角星",
|
|
22
|
-
rhombus: "菱形",
|
|
23
|
-
triangle: "三角形",
|
|
24
|
-
speechBalloon: "气泡",
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
</script>
|
|
28
|
-
|
|
29
|
-
<script lang="ts">
|
|
30
|
-
import type { Appliance, FastboardApp, HotKey } from "@netless/fastboard-core";
|
|
31
|
-
import { tippy } from "../../../actions/tippy";
|
|
32
|
-
import { shapes, shapesIcon, shapesIconActive, applianceShapes } from "./constants";
|
|
33
|
-
import { tooltip } from "./helper";
|
|
34
|
-
|
|
35
|
-
export let app: FastboardApp | null | undefined = null;
|
|
36
|
-
export let theme: Theme = "light";
|
|
37
|
-
export let language: Language = "en";
|
|
38
|
-
export let disabled = false;
|
|
39
|
-
|
|
40
|
-
$: t = i18n[language];
|
|
41
|
-
$: memberState = app?.memberState;
|
|
42
|
-
$: appliance = $memberState?.currentApplianceName;
|
|
43
|
-
$: shape = $memberState?.shapeType;
|
|
44
|
-
$: hotkeys = app?.hotKeys;
|
|
45
|
-
let c: Partial<Record<Shape, HotKey>>;
|
|
46
|
-
$: c = {
|
|
47
|
-
rectangle: hotkeys?.changeToRectangle,
|
|
48
|
-
ellipse: hotkeys?.changeToEllipse,
|
|
49
|
-
straight: hotkeys?.changeToStraight,
|
|
50
|
-
arrow: hotkeys?.changeToArrow,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function set_appliance_or_shape(ev: MouseEvent) {
|
|
54
|
-
let button = ev.target as HTMLButtonElement | null;
|
|
55
|
-
if (button && button.dataset.shapeKey) {
|
|
56
|
-
let shape = button.dataset.shapeKey as Shape;
|
|
57
|
-
if (shape && app) {
|
|
58
|
-
if (applianceShapes.includes(shape as Appliance)) {
|
|
59
|
-
app.setAppliance(shape as Appliance);
|
|
60
|
-
} else {
|
|
61
|
-
app.setAppliance("shape", shape as Exclude<Shape, Appliance>);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
</script>
|
|
67
|
-
|
|
68
|
-
<div class="fastboard-toolbar-shapes {theme}" on:click={set_appliance_or_shape}>
|
|
69
|
-
{#each shapes as key (key)}
|
|
70
|
-
{@const is_selected = appliance === "shape" ? shape === key : appliance === key}
|
|
71
|
-
<button
|
|
72
|
-
class="fastboard-toolbar-btn fastboard-toolbar-shape-btn {theme} {key}"
|
|
73
|
-
class:is-active={is_selected}
|
|
74
|
-
data-shape-key={key}
|
|
75
|
-
{disabled}
|
|
76
|
-
use:tippy={{ content: tooltip(t[key], c[key]), placement: "top" }}
|
|
77
|
-
>
|
|
78
|
-
{#if is_selected}
|
|
79
|
-
<svelte:component this={shapesIconActive[key]} {theme} active />
|
|
80
|
-
{:else}
|
|
81
|
-
<svelte:component this={shapesIcon[key]} {theme} />
|
|
82
|
-
{/if}
|
|
83
|
-
</button>
|
|
84
|
-
{/each}
|
|
85
|
-
</div>
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
import type { I18nData, Language, Theme } from "../../../typings";
|
|
3
|
+
import type { Shape } from "./constants";
|
|
4
|
+
|
|
5
|
+
const i18n: I18nData<Shape> = {
|
|
6
|
+
en: {
|
|
7
|
+
rectangle: "Rectangle",
|
|
8
|
+
ellipse: "Ellipse",
|
|
9
|
+
straight: "Line",
|
|
10
|
+
arrow: "Arrow",
|
|
11
|
+
pentagram: "Star",
|
|
12
|
+
rhombus: "Diamond",
|
|
13
|
+
triangle: "Triangle",
|
|
14
|
+
speechBalloon: "Balloon",
|
|
15
|
+
},
|
|
16
|
+
"zh-CN": {
|
|
17
|
+
rectangle: "矩形",
|
|
18
|
+
ellipse: "椭圆",
|
|
19
|
+
straight: "直线",
|
|
20
|
+
arrow: "箭头",
|
|
21
|
+
pentagram: "五角星",
|
|
22
|
+
rhombus: "菱形",
|
|
23
|
+
triangle: "三角形",
|
|
24
|
+
speechBalloon: "气泡",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<script lang="ts">
|
|
30
|
+
import type { Appliance, FastboardApp, HotKey } from "@netless/fastboard-core";
|
|
31
|
+
import { tippy } from "../../../actions/tippy";
|
|
32
|
+
import { shapes, shapesIcon, shapesIconActive, applianceShapes } from "./constants";
|
|
33
|
+
import { tooltip } from "./helper";
|
|
34
|
+
|
|
35
|
+
export let app: FastboardApp | null | undefined = null;
|
|
36
|
+
export let theme: Theme = "light";
|
|
37
|
+
export let language: Language = "en";
|
|
38
|
+
export let disabled = false;
|
|
39
|
+
|
|
40
|
+
$: t = i18n[language];
|
|
41
|
+
$: memberState = app?.memberState;
|
|
42
|
+
$: appliance = $memberState?.currentApplianceName;
|
|
43
|
+
$: shape = $memberState?.shapeType;
|
|
44
|
+
$: hotkeys = app?.hotKeys;
|
|
45
|
+
let c: Partial<Record<Shape, HotKey>>;
|
|
46
|
+
$: c = {
|
|
47
|
+
rectangle: hotkeys?.changeToRectangle,
|
|
48
|
+
ellipse: hotkeys?.changeToEllipse,
|
|
49
|
+
straight: hotkeys?.changeToStraight,
|
|
50
|
+
arrow: hotkeys?.changeToArrow,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
function set_appliance_or_shape(ev: MouseEvent) {
|
|
54
|
+
let button = ev.target as HTMLButtonElement | null;
|
|
55
|
+
if (button && button.dataset.shapeKey) {
|
|
56
|
+
let shape = button.dataset.shapeKey as Shape;
|
|
57
|
+
if (shape && app) {
|
|
58
|
+
if (applianceShapes.includes(shape as Appliance)) {
|
|
59
|
+
app.setAppliance(shape as Appliance);
|
|
60
|
+
} else {
|
|
61
|
+
app.setAppliance("shape", shape as Exclude<Shape, Appliance>);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
</script>
|
|
67
|
+
|
|
68
|
+
<div class="fastboard-toolbar-shapes {theme}" on:click={set_appliance_or_shape}>
|
|
69
|
+
{#each shapes as key (key)}
|
|
70
|
+
{@const is_selected = appliance === "shape" ? shape === key : appliance === key}
|
|
71
|
+
<button
|
|
72
|
+
class="fastboard-toolbar-btn fastboard-toolbar-shape-btn {theme} {key}"
|
|
73
|
+
class:is-active={is_selected}
|
|
74
|
+
data-shape-key={key}
|
|
75
|
+
{disabled}
|
|
76
|
+
use:tippy={{ content: tooltip(t[key], c[key]), placement: "top" }}
|
|
77
|
+
>
|
|
78
|
+
{#if is_selected}
|
|
79
|
+
<svelte:component this={shapesIconActive[key]} {theme} active />
|
|
80
|
+
{:else}
|
|
81
|
+
<svelte:component this={shapesIcon[key]} {theme} />
|
|
82
|
+
{/if}
|
|
83
|
+
</button>
|
|
84
|
+
{/each}
|
|
85
|
+
</div>
|