@netless/fastboard-ui 0.3.0-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +21 -0
- package/README.md +7 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +10143 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +10114 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.svelte.mjs +10368 -0
- package/dist/index.svelte.mjs.map +1 -0
- package/package.json +31 -0
- package/src/actions/height.ts +43 -0
- package/src/actions/scroll.ts +31 -0
- package/src/actions/tippy.ts +70 -0
- package/src/behaviors/icons/countdown.svg +1 -0
- package/src/behaviors/icons/geogebra.svg +1 -0
- package/src/behaviors/icons/visual-studio-code.svg +1 -0
- package/src/behaviors/index.ts +68 -0
- package/src/components/Button/Button.svelte +51 -0
- package/src/components/Button/Button.svelte.d.ts +26 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/Fastboard/Fastboard.scss +49 -0
- package/src/components/Fastboard/Fastboard.svelte +32 -0
- package/src/components/Fastboard/Fastboard.svelte.ts +12 -0
- package/src/components/Fastboard/ReplayFastboard.svelte +22 -0
- package/src/components/Fastboard/ReplayFastboard.svelte.ts +12 -0
- package/src/components/Fastboard/index.ts +5 -0
- package/src/components/Icon/Icon.svelte +11 -0
- package/src/components/Icon/Icon.svelte.d.ts +10 -0
- package/src/components/Icon/index.ts +2 -0
- package/src/components/Icons/Apps.svelte +49 -0
- package/src/components/Icons/Arrow.svelte +16 -0
- package/src/components/Icons/ArrowBolded.svelte +17 -0
- package/src/components/Icons/Balloon.svelte +16 -0
- package/src/components/Icons/BalloonBolded.svelte +16 -0
- package/src/components/Icons/Circle.svelte +20 -0
- package/src/components/Icons/CircleBolded.svelte +20 -0
- package/src/components/Icons/Clean.svelte +14 -0
- package/src/components/Icons/Clear.svelte +16 -0
- package/src/components/Icons/Click.svelte +16 -0
- package/src/components/Icons/ClickFilled.svelte +10 -0
- package/src/components/Icons/Diamond.svelte +16 -0
- package/src/components/Icons/Down.svelte +16 -0
- package/src/components/Icons/Eraser.svelte +16 -0
- package/src/components/Icons/EraserFilled.svelte +16 -0
- package/src/components/Icons/Icons.scss +20 -0
- package/src/components/Icons/Left.svelte +16 -0
- package/src/components/Icons/Line.svelte +16 -0
- package/src/components/Icons/LineBolded.svelte +16 -0
- package/src/components/Icons/Loading.svelte +10 -0
- package/src/components/Icons/Minus.svelte +16 -0
- package/src/components/Icons/Pause.svelte +10 -0
- package/src/components/Icons/Pencil.svelte +29 -0
- package/src/components/Icons/PencilFilled.svelte +16 -0
- package/src/components/Icons/Play.svelte +10 -0
- package/src/components/Icons/Plus.svelte +16 -0
- package/src/components/Icons/Rectangle.svelte +16 -0
- package/src/components/Icons/RectangleBolded.svelte +16 -0
- package/src/components/Icons/Redo.svelte +15 -0
- package/src/components/Icons/Reset.svelte +26 -0
- package/src/components/Icons/Rhombus.svelte +16 -0
- package/src/components/Icons/RhombusBolded.svelte +16 -0
- package/src/components/Icons/Right.svelte +16 -0
- package/src/components/Icons/Selector.svelte +24 -0
- package/src/components/Icons/SelectorFilled.svelte +18 -0
- package/src/components/Icons/SpeechBalloon.svelte +16 -0
- package/src/components/Icons/Star.svelte +16 -0
- package/src/components/Icons/StarBolded.svelte +16 -0
- package/src/components/Icons/Text.svelte +16 -0
- package/src/components/Icons/TextFilled.svelte +17 -0
- package/src/components/Icons/Triangle.svelte +16 -0
- package/src/components/Icons/TriangleBolded.svelte +16 -0
- package/src/components/Icons/Undo.svelte +15 -0
- package/src/components/Icons/Up.svelte +16 -0
- package/src/components/Icons/WhiteboardAdd.svelte +34 -0
- package/src/components/Icons/index.ts +93 -0
- package/src/components/PageControl/PageControl.scss +15 -0
- package/src/components/PageControl/PageControl.svelte +78 -0
- package/src/components/PageControl/PageControl.svelte.d.ts +13 -0
- package/src/components/PageControl/index.ts +2 -0
- package/src/components/PlayerControl/PlayerControl.scss +57 -0
- package/src/components/PlayerControl/PlayerControl.svelte +153 -0
- package/src/components/PlayerControl/PlayerControl.svelte.d.ts +13 -0
- package/src/components/PlayerControl/index.ts +2 -0
- package/src/components/RedoUndo/RedoUndo.scss +11 -0
- package/src/components/RedoUndo/RedoUndo.svelte +60 -0
- package/src/components/RedoUndo/RedoUndo.svelte.d.ts +13 -0
- package/src/components/RedoUndo/index.ts +2 -0
- package/src/components/Toolbar/README.md +57 -0
- package/src/components/Toolbar/Toolbar.scss +69 -0
- package/src/components/Toolbar/Toolbar.svelte +50 -0
- package/src/components/Toolbar/Toolbar.svelte.d.ts +12 -0
- package/src/components/Toolbar/components/Contents.scss +166 -0
- package/src/components/Toolbar/components/Contents.svelte +191 -0
- package/src/components/Toolbar/components/Shapes.svelte +85 -0
- package/src/components/Toolbar/components/Slider.scss +119 -0
- package/src/components/Toolbar/components/Slider.svelte +54 -0
- package/src/components/Toolbar/components/StrokeColor.svelte +39 -0
- package/src/components/Toolbar/components/StrokeWidth.svelte +20 -0
- package/src/components/Toolbar/components/constants.ts +80 -0
- package/src/components/Toolbar/components/helper.ts +24 -0
- package/src/components/Toolbar/index.ts +2 -0
- package/src/components/ZoomControl/ZoomControl.scss +15 -0
- package/src/components/ZoomControl/ZoomControl.svelte +99 -0
- package/src/components/ZoomControl/ZoomControl.svelte.d.ts +13 -0
- package/src/components/ZoomControl/index.ts +2 -0
- package/src/components/helpers.ts +3 -0
- package/src/components/theme.scss +91 -0
- package/src/components/variables.scss +69 -0
- package/src/index.ts +13 -0
- package/src/style.scss +36 -0
- package/src/typings.ts +17 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
@import "../theme.scss";
|
|
2
|
+
|
|
3
|
+
$name: "fastboard-toolbar";
|
|
4
|
+
|
|
5
|
+
.#{$name} {
|
|
6
|
+
height: 100%;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
position: relative;
|
|
10
|
+
transform: translateX(0);
|
|
11
|
+
transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
12
|
+
|
|
13
|
+
&.collapsed {
|
|
14
|
+
transform: translateX(-100%);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.#{$name}-handler {
|
|
19
|
+
position: absolute;
|
|
20
|
+
left: 100%;
|
|
21
|
+
width: 17px;
|
|
22
|
+
font-size: 0;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
|
|
25
|
+
input[type="checkbox"] {
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
appearance: none;
|
|
30
|
+
margin: 0;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 100%;
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
svg {
|
|
37
|
+
opacity: 0;
|
|
38
|
+
transition: opacity 0.5s 1s;
|
|
39
|
+
pointer-events: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@each $name, $theme in $themes {
|
|
43
|
+
&.#{$name} &-bg-color {
|
|
44
|
+
fill: read($theme, "bg-color");
|
|
45
|
+
}
|
|
46
|
+
&.#{$name} &-border-color {
|
|
47
|
+
stroke: read($theme, "border-color");
|
|
48
|
+
}
|
|
49
|
+
&.#{$name} &-image-stroke-color {
|
|
50
|
+
stroke: read($theme, "color");
|
|
51
|
+
}
|
|
52
|
+
&.#{$name} &-image-fill-color {
|
|
53
|
+
fill: read($theme, "color");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.#{$name}:hover .#{$name}-handler svg,
|
|
59
|
+
.#{$name}.collapsed .#{$name}-handler svg {
|
|
60
|
+
opacity: 1;
|
|
61
|
+
transition: opacity 0.2s;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.#{$name}-btn {
|
|
65
|
+
@include btn(32px, 4px);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@import "./components/Slider.scss";
|
|
69
|
+
@import "./components/Contents.scss";
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Language, Theme } from "../../typings";
|
|
4
|
+
import { writable as svelte_writable } from "svelte/store";
|
|
5
|
+
import { height } from "../../actions/height";
|
|
6
|
+
import { clamp } from "../helpers";
|
|
7
|
+
import Contents from "./components/Contents.svelte";
|
|
8
|
+
|
|
9
|
+
export let app: FastboardApp | null | undefined = null;
|
|
10
|
+
export let theme: Theme = "light";
|
|
11
|
+
export let language: Language = "en";
|
|
12
|
+
|
|
13
|
+
const name = "fastboard-toolbar";
|
|
14
|
+
const extra_height = (32 + 4 + 4) * 2;
|
|
15
|
+
|
|
16
|
+
$: writable = app?.writable;
|
|
17
|
+
$: disabled = !$writable;
|
|
18
|
+
|
|
19
|
+
let collapsed = false;
|
|
20
|
+
let container_height = svelte_writable(0);
|
|
21
|
+
let scroll_height = svelte_writable(0);
|
|
22
|
+
|
|
23
|
+
$: computed_height = clamp($container_height, extra_height, $scroll_height + extra_height);
|
|
24
|
+
$: scrollable = $scroll_height + extra_height > $container_height;
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<div class="{name} {theme}" class:collapsed use:height={container_height}>
|
|
28
|
+
<div class="{name}-contents {theme}" style:height={scrollable ? computed_height + "px" : "auto"}>
|
|
29
|
+
<Contents {app} {theme} {language} {disabled} {scroll_height} {computed_height} {scrollable} />
|
|
30
|
+
</div>
|
|
31
|
+
<label class="{name}-handler {theme}">
|
|
32
|
+
<input type="checkbox" bind:checked={collapsed} />
|
|
33
|
+
<svg fill="none" stroke-width="2" viewBox="0 0 32 120">
|
|
34
|
+
<path
|
|
35
|
+
fill="#fff"
|
|
36
|
+
stroke="none"
|
|
37
|
+
d="m0 0 24 16q6 4 6 14v60q0 10-6 14L0 120"
|
|
38
|
+
class="{name}-handler-bg-color"
|
|
39
|
+
/>
|
|
40
|
+
<path stroke="#000" d="m0 0 24 16q6 4 6 14v60q0 10-6 14L0 120" class="{name}-handler-border-color" />
|
|
41
|
+
{#if collapsed}
|
|
42
|
+
<path stroke="#000" d="M10 52v16" class="{name}-handler-image-stroke-color" />
|
|
43
|
+
<path fill="#000" stroke="none" d="M14 52v16l8-8z" class="{name}-handler-image-fill-color" />
|
|
44
|
+
{:else}
|
|
45
|
+
<path stroke="#000" d="M20 52v16" class="{name}-handler-image-stroke-color" />
|
|
46
|
+
<path fill="#000" stroke="none" d="M16 52v16l-8-8z" class="{name}-handler-image-fill-color" />
|
|
47
|
+
{/if}
|
|
48
|
+
</svg>
|
|
49
|
+
</label>
|
|
50
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FastboardApp } from "@netless/fastboard-core";
|
|
2
|
+
import type { Theme, Language } from "../../typings";
|
|
3
|
+
import { SvelteComponentTyped } from "svelte";
|
|
4
|
+
|
|
5
|
+
export declare interface ToolbarProps {
|
|
6
|
+
app?: FastboardApp | null;
|
|
7
|
+
theme?: Theme;
|
|
8
|
+
language?: Language;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare class Toolbar extends SvelteComponentTyped<ToolbarProps> {}
|
|
12
|
+
export default Toolbar;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
@import "../../theme.scss";
|
|
2
|
+
|
|
3
|
+
$name: "fastboard-toolbar";
|
|
4
|
+
|
|
5
|
+
.#{$name}-contents {
|
|
6
|
+
@include container;
|
|
7
|
+
padding: 2px 0;
|
|
8
|
+
gap: 0;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
|
|
11
|
+
> .#{$name}-btn {
|
|
12
|
+
margin: 2px 4px;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.#{$name}-btn-interactive {
|
|
17
|
+
position: relative;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.#{$name}-triangle {
|
|
21
|
+
width: 0px;
|
|
22
|
+
height: 0px;
|
|
23
|
+
border-bottom: 4px solid;
|
|
24
|
+
border-left: 4px solid transparent;
|
|
25
|
+
position: absolute;
|
|
26
|
+
bottom: 0;
|
|
27
|
+
right: 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.#{$name}-btn:focus + .#{$name}-triangle {
|
|
31
|
+
opacity: 0;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.#{$name}-scrollable {
|
|
35
|
+
padding: 2px 4px;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 4px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.#{$name}-tooltip {
|
|
43
|
+
display: inline-flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
gap: 4px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.#{$name}-hotkey {
|
|
49
|
+
display: inline-flex;
|
|
50
|
+
margin-right: -4px;
|
|
51
|
+
width: 24px;
|
|
52
|
+
height: 24px;
|
|
53
|
+
align-items: center;
|
|
54
|
+
justify-content: center;
|
|
55
|
+
background-color: rgba(#fff, 0.1);
|
|
56
|
+
border-radius: 4px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.#{$name}-panel-wrapper {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.#{$name}-panel {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.#{$name}-panel-divider {
|
|
69
|
+
height: 0.5px;
|
|
70
|
+
width: 100%;
|
|
71
|
+
margin: 4px 0;
|
|
72
|
+
background-color: rgba(#fff, 0.15);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.#{$name}-colors,
|
|
76
|
+
.#{$name}-shapes {
|
|
77
|
+
display: grid;
|
|
78
|
+
align-self: center;
|
|
79
|
+
grid-template: repeat(2, 1fr) / repeat(4, 1fr);
|
|
80
|
+
align-items: center;
|
|
81
|
+
justify-items: center;
|
|
82
|
+
gap: 4px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.#{$name}-shape-btn {
|
|
86
|
+
width: 24px;
|
|
87
|
+
height: 24px;
|
|
88
|
+
padding: 0;
|
|
89
|
+
display: inline-flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.#{$name}-color-btn {
|
|
95
|
+
@extend .#{$name}-shape-btn;
|
|
96
|
+
border: 1px solid transparent;
|
|
97
|
+
|
|
98
|
+
@each $name, $theme in $themes {
|
|
99
|
+
&.#{$name}.is-active {
|
|
100
|
+
border-color: read($theme, "active-color");
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.#{$name}-color-item {
|
|
106
|
+
display: inline-block;
|
|
107
|
+
width: 16px;
|
|
108
|
+
height: 16px;
|
|
109
|
+
border-radius: 4px;
|
|
110
|
+
pointer-events: none;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.#{$name}-panel.apps {
|
|
114
|
+
display: grid;
|
|
115
|
+
grid-template-columns: repeat(3, 1fr);
|
|
116
|
+
gap: 4px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.#{$name}-app-btn {
|
|
120
|
+
margin: 0;
|
|
121
|
+
border: 0;
|
|
122
|
+
padding: 4px;
|
|
123
|
+
background-color: transparent;
|
|
124
|
+
display: inline-flex;
|
|
125
|
+
flex-direction: column;
|
|
126
|
+
align-items: center;
|
|
127
|
+
gap: 4px;
|
|
128
|
+
font-size: 0;
|
|
129
|
+
|
|
130
|
+
&:disabled {
|
|
131
|
+
opacity: 0.8;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&-icon {
|
|
135
|
+
width: 32px;
|
|
136
|
+
height: 32px;
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&-text {
|
|
141
|
+
font-size: 14px;
|
|
142
|
+
max-width: 100%;
|
|
143
|
+
overflow: hidden;
|
|
144
|
+
text-overflow: ellipsis;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&.is-loading {
|
|
148
|
+
cursor: progress;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.is-failed {
|
|
152
|
+
cursor: not-allowed;
|
|
153
|
+
opacity: 0.5;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
@each $name, $theme in $themes {
|
|
157
|
+
&:not(:disabled, .is-loading, .is-failed):hover.#{$name} {
|
|
158
|
+
cursor: pointer;
|
|
159
|
+
background-color: read($theme, "hover-bg-color");
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
&-text.#{$name} {
|
|
163
|
+
color: read($theme, "color");
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
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 Shapes from "./Shapes.svelte";
|
|
20
|
+
|
|
21
|
+
export let app: FastboardApp | null | undefined = null;
|
|
22
|
+
export let theme: Theme = "light";
|
|
23
|
+
export let language: Language = "en";
|
|
24
|
+
export let disabled = false;
|
|
25
|
+
export let scroll_height: Writable<number>;
|
|
26
|
+
export let computed_height = 0;
|
|
27
|
+
export let scrollable = false;
|
|
28
|
+
|
|
29
|
+
const name = "fastboard-toolbar";
|
|
30
|
+
|
|
31
|
+
let last_shape: Shape = "rectangle";
|
|
32
|
+
|
|
33
|
+
let pencil_panel: HTMLDivElement;
|
|
34
|
+
let text_panel: HTMLDivElement;
|
|
35
|
+
let shapes_panel: HTMLDivElement;
|
|
36
|
+
let apps_panel: HTMLDivElement;
|
|
37
|
+
|
|
38
|
+
let btn_props: { name: string; theme: Theme; disabled: boolean; placement: Placement };
|
|
39
|
+
$: btn_props = { name, theme, disabled, placement: "right" };
|
|
40
|
+
$: t = i18n[language];
|
|
41
|
+
$: hotkeys = app?.hotKeys;
|
|
42
|
+
$: c = {
|
|
43
|
+
clicker: tooltip(t.clicker, hotkeys?.changeToClick),
|
|
44
|
+
selector: tooltip(t.selector, hotkeys?.changeToSelector),
|
|
45
|
+
pencil: tooltip(t.pencil, hotkeys?.changeToPencil),
|
|
46
|
+
eraser: tooltip(t.eraser, hotkeys?.changeToEraser),
|
|
47
|
+
text: tooltip(t.text, hotkeys?.changeToText),
|
|
48
|
+
};
|
|
49
|
+
$: memberState = app?.memberState;
|
|
50
|
+
$: appliance = $memberState?.currentApplianceName;
|
|
51
|
+
$: shape = $memberState?.shapeType;
|
|
52
|
+
$: status = app?.appsStatus;
|
|
53
|
+
|
|
54
|
+
let top = writable(0);
|
|
55
|
+
$: max_scroll = scrollable ? $scroll_height + (32 + 8) * 2 - computed_height : 0;
|
|
56
|
+
|
|
57
|
+
function scroll_up() {
|
|
58
|
+
$top = clamp($top - 32 - 4, 0, max_scroll);
|
|
59
|
+
}
|
|
60
|
+
function scroll_down() {
|
|
61
|
+
$top = clamp($top + 32 + 4, 0, max_scroll);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function clicker() {
|
|
65
|
+
app?.setAppliance("clicker");
|
|
66
|
+
}
|
|
67
|
+
function selector() {
|
|
68
|
+
app?.setAppliance("selector");
|
|
69
|
+
}
|
|
70
|
+
function pencil() {
|
|
71
|
+
app?.setAppliance("pencil");
|
|
72
|
+
}
|
|
73
|
+
function text() {
|
|
74
|
+
app?.setAppliance("text");
|
|
75
|
+
}
|
|
76
|
+
function select_last_shape() {
|
|
77
|
+
if (applianceShapes.includes(last_shape as Appliance)) {
|
|
78
|
+
app?.setAppliance(last_shape as Appliance);
|
|
79
|
+
} else {
|
|
80
|
+
app?.setAppliance("shape", last_shape as Exclude<Shape, Appliance>);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
$: if (applianceShapes.includes(appliance as Appliance)) {
|
|
84
|
+
last_shape = appliance as Shape;
|
|
85
|
+
} else if (shape) {
|
|
86
|
+
last_shape = shape;
|
|
87
|
+
}
|
|
88
|
+
function eraser() {
|
|
89
|
+
app?.setAppliance("eraser");
|
|
90
|
+
}
|
|
91
|
+
function clear() {
|
|
92
|
+
app?.cleanCurrentScene();
|
|
93
|
+
}
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
{#if scrollable}
|
|
97
|
+
<Button class="scroll-up" {...btn_props} on:click={scroll_up}>
|
|
98
|
+
<Icons.Up {theme} />
|
|
99
|
+
</Button>
|
|
100
|
+
{/if}
|
|
101
|
+
<div class="{name}-scrollable" class:scrollable use:scrollHeight={scroll_height} use:scrollTop={top}>
|
|
102
|
+
<Button class="clicker" {...btn_props} on:click={clicker} content={c.clicker}>
|
|
103
|
+
{#if appliance === "clicker"}
|
|
104
|
+
<Icons.ClickFilled {theme} active />
|
|
105
|
+
{:else}
|
|
106
|
+
<Icons.Click {theme} />
|
|
107
|
+
{/if}
|
|
108
|
+
</Button>
|
|
109
|
+
<Button class="selector" {...btn_props} on:click={selector} content={c.selector}>
|
|
110
|
+
{#if appliance === "selector"}
|
|
111
|
+
<Icons.SelectorFilled {theme} active />
|
|
112
|
+
{:else}
|
|
113
|
+
<Icons.Selector {theme} />
|
|
114
|
+
{/if}
|
|
115
|
+
</Button>
|
|
116
|
+
<Button class="pencil" {...btn_props} on:click={pencil} content={c.pencil} menu={pencil_panel}>
|
|
117
|
+
{#if appliance === "pencil"}
|
|
118
|
+
<Icons.PencilFilled {theme} active />
|
|
119
|
+
{:else}
|
|
120
|
+
<Icons.Pencil {theme} />
|
|
121
|
+
{/if}
|
|
122
|
+
</Button>
|
|
123
|
+
<Button class="text" {...btn_props} on:click={text} content={c.text} menu={text_panel}>
|
|
124
|
+
{#if appliance === "text"}
|
|
125
|
+
<Icons.TextFilled {theme} active />
|
|
126
|
+
{:else}
|
|
127
|
+
<Icons.Text {theme} />
|
|
128
|
+
{/if}
|
|
129
|
+
</Button>
|
|
130
|
+
<Button class="shapes" {...btn_props} on:click={select_last_shape} content={t.shapes} menu={shapes_panel}>
|
|
131
|
+
{#if appliance === last_shape || (appliance === "shape" && shape === last_shape)}
|
|
132
|
+
<svelte:component this={shapesIconActive[last_shape]} {theme} active />
|
|
133
|
+
{:else}
|
|
134
|
+
<svelte:component this={shapesIcon[last_shape]} {theme} />
|
|
135
|
+
{/if}
|
|
136
|
+
</Button>
|
|
137
|
+
<Button class="eraser" {...btn_props} on:click={eraser} content={c.eraser}>
|
|
138
|
+
{#if appliance === "eraser"}
|
|
139
|
+
<Icons.EraserFilled {theme} active />
|
|
140
|
+
{:else}
|
|
141
|
+
<Icons.Eraser {theme} />
|
|
142
|
+
{/if}
|
|
143
|
+
</Button>
|
|
144
|
+
<Button class="clear" {...btn_props} on:click={clear} content={t.clear}>
|
|
145
|
+
<Icons.Clear {theme} />
|
|
146
|
+
</Button>
|
|
147
|
+
<Button class="apps" {...btn_props} content={t.apps} menu={apps_panel} menu_placement="right-end">
|
|
148
|
+
<Icons.Apps {theme} />
|
|
149
|
+
</Button>
|
|
150
|
+
</div>
|
|
151
|
+
{#if scrollable}
|
|
152
|
+
<Button class="scroll-down" {name} {theme} {disabled} on:click={scroll_down}>
|
|
153
|
+
<Icons.Down {theme} />
|
|
154
|
+
</Button>
|
|
155
|
+
{/if}
|
|
156
|
+
|
|
157
|
+
<div class="{name}-panel-wrapper" style="display:none">
|
|
158
|
+
<div class="{name}-panel pencil" bind:this={pencil_panel}>
|
|
159
|
+
<StrokeWidth {app} {theme} {disabled} />
|
|
160
|
+
<div class="{name}-panel-divider" />
|
|
161
|
+
<StrokeColor {app} {theme} {disabled} />
|
|
162
|
+
</div>
|
|
163
|
+
<div class="{name}-panel text" bind:this={text_panel}>
|
|
164
|
+
<StrokeColor {app} {theme} {disabled} />
|
|
165
|
+
</div>
|
|
166
|
+
<div class="{name}-panel shapes" bind:this={shapes_panel}>
|
|
167
|
+
<Shapes {app} {theme} {language} {disabled} />
|
|
168
|
+
<div class="{name}-panel-divider" />
|
|
169
|
+
<StrokeWidth {app} {theme} {disabled} />
|
|
170
|
+
<div class="{name}-panel-divider" />
|
|
171
|
+
<StrokeColor {app} {theme} {disabled} />
|
|
172
|
+
</div>
|
|
173
|
+
<div class="{name}-panel apps" bind:this={apps_panel}>
|
|
174
|
+
{#each apps.data as netless_app (netless_app.kind)}
|
|
175
|
+
{@const { icon, label, kind, onClick } = netless_app}
|
|
176
|
+
{@const state = $status && $status[kind]}
|
|
177
|
+
<button
|
|
178
|
+
class="{name}-app-btn {kind} {theme}"
|
|
179
|
+
class:is-loading={state && state.status === "loading"}
|
|
180
|
+
class:is-failed={state && state.status === "failed"}
|
|
181
|
+
title={label + (state && state.reason ? ": " + state.reason : "")}
|
|
182
|
+
data-app-kind={netless_app.kind}
|
|
183
|
+
disabled={state && state.status !== "idle"}
|
|
184
|
+
on:click={app && onClick.bind(null, app)}
|
|
185
|
+
>
|
|
186
|
+
<img class="{name}-app-btn-icon {theme}" src={icon} alt={kind} title={label} />
|
|
187
|
+
<span class="{name}-app-btn-text {theme}">{label}</span>
|
|
188
|
+
</button>
|
|
189
|
+
{/each}
|
|
190
|
+
</div>
|
|
191
|
+
</div>
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@import "../../theme.scss";
|
|
3
|
+
|
|
4
|
+
$active-shadow-width: 3px;
|
|
5
|
+
$thumb-height: 13px;
|
|
6
|
+
$track-height: 5px;
|
|
7
|
+
$shadow-color: hsl(210deg 15% 16%);
|
|
8
|
+
$thumb-color: white;
|
|
9
|
+
|
|
10
|
+
@mixin track {
|
|
11
|
+
border: 0;
|
|
12
|
+
border-radius: calc($track-height / 2);
|
|
13
|
+
height: $track-height;
|
|
14
|
+
transition: box-shadow 0.3s ease;
|
|
15
|
+
user-select: none;
|
|
16
|
+
background-color: rgba(grey, $alpha: 0.25);
|
|
17
|
+
-webkit-user-select: none;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@mixin thumb {
|
|
21
|
+
appearance: none;
|
|
22
|
+
background: $thumb-color;
|
|
23
|
+
border: 0;
|
|
24
|
+
border-radius: 100%;
|
|
25
|
+
box-shadow: 0 1px 1px rgba($shadow-color, 0.15), 0 0 0 1px rgba($shadow-color, 0.2);
|
|
26
|
+
width: $thumb-height;
|
|
27
|
+
height: $thumb-height;
|
|
28
|
+
position: relative;
|
|
29
|
+
transition: all 0.2s ease;
|
|
30
|
+
cursor: grab;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.fastboard-slider {
|
|
34
|
+
@include border-box;
|
|
35
|
+
|
|
36
|
+
position: relative;
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 100%;
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.fastboard-slider-track {
|
|
44
|
+
appearance: none;
|
|
45
|
+
background: transparent;
|
|
46
|
+
border: 0;
|
|
47
|
+
border-radius: $thumb-height * 2;
|
|
48
|
+
|
|
49
|
+
flex: 1;
|
|
50
|
+
display: block;
|
|
51
|
+
height: calc($active-shadow-width * 2 + $thumb-height);
|
|
52
|
+
margin: 0;
|
|
53
|
+
width: 0;
|
|
54
|
+
min-width: 0;
|
|
55
|
+
padding: 0;
|
|
56
|
+
transition: box-shadow 0.3s ease;
|
|
57
|
+
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
touch-action: manipulation;
|
|
60
|
+
|
|
61
|
+
&::-webkit-slider-runnable-track {
|
|
62
|
+
@include track;
|
|
63
|
+
|
|
64
|
+
background-image: linear-gradient(to right, currentColor var(--value, 0%), transparent var(--value, 0%));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&::-webkit-slider-thumb {
|
|
68
|
+
@include thumb;
|
|
69
|
+
|
|
70
|
+
appearance: none;
|
|
71
|
+
margin-top: calc(($thumb-height - $track-height) / 2 * -1);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
&::-moz-range-track {
|
|
75
|
+
@include track;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&::-moz-range-thumb {
|
|
79
|
+
@include thumb;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&::-moz-range-progress {
|
|
83
|
+
background: currentColor;
|
|
84
|
+
border-radius: calc($track-height / 2);
|
|
85
|
+
height: $track-height;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
&::-ms-track {
|
|
89
|
+
@include track;
|
|
90
|
+
|
|
91
|
+
color: transparent;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
&::-ms-thumb {
|
|
95
|
+
@include thumb;
|
|
96
|
+
|
|
97
|
+
margin-top: 0;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
&::-ms-tooltip {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&::-moz-focus-outer {
|
|
105
|
+
border: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
&.grabbing {
|
|
109
|
+
&::-webkit-slider-thumb {
|
|
110
|
+
cursor: grabbing;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@each $name, $theme in $themes {
|
|
115
|
+
&.#{$name} {
|
|
116
|
+
color: read($theme, "active-color");
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|