@netless/fastboard-ui 0.3.2-canary.5 → 0.3.3
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 +102 -102
- package/dist/index.js +30 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -23
- package/dist/index.mjs.map +1 -1
- package/dist/index.svelte.mjs +22 -17
- package/dist/index.svelte.mjs.map +1 -1
- package/package.json +4 -5
- 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 -74
- 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 -80
- package/src/components/Fastboard/Fastboard.svelte.ts +14 -14
- 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 -62
- package/src/components/Toolbar/Toolbar.svelte.d.ts +13 -13
- package/src/components/Toolbar/components/Contents.scss +168 -168
- package/src/components/Toolbar/components/Contents.svelte +202 -197
- 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 -39
- 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 -38
|
@@ -1,119 +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
|
-
}
|
|
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
|
+
}
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Theme } from "../../../typings";
|
|
3
|
-
import { createEventDispatcher } from "svelte";
|
|
4
|
-
|
|
5
|
-
const dispatch = createEventDispatcher<{ change: number }>();
|
|
6
|
-
|
|
7
|
-
let className = "";
|
|
8
|
-
export { className as class };
|
|
9
|
-
export let theme: Theme = "light";
|
|
10
|
-
export let min = 0;
|
|
11
|
-
export let max = 100;
|
|
12
|
-
export let step = 0.01;
|
|
13
|
-
export let value = 30;
|
|
14
|
-
export let disabled = false;
|
|
15
|
-
|
|
16
|
-
const name = "fastboard-slider";
|
|
17
|
-
|
|
18
|
-
let real_value = value;
|
|
19
|
-
let grabbing = false;
|
|
20
|
-
|
|
21
|
-
function on_down() {
|
|
22
|
-
grabbing = true;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function on_change() {
|
|
26
|
-
grabbing = false;
|
|
27
|
-
value = real_value;
|
|
28
|
-
dispatch("change", value);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
$: if (value !== real_value && !grabbing) {
|
|
32
|
-
real_value = value;
|
|
33
|
-
}
|
|
34
|
-
$: percent = (100 * (real_value - min)) / (max - min);
|
|
35
|
-
</script>
|
|
36
|
-
|
|
37
|
-
<div class="{name} {className} {theme}" style="--value:{percent}%">
|
|
38
|
-
<input
|
|
39
|
-
class="{name}-track {theme}"
|
|
40
|
-
class:grabbing
|
|
41
|
-
type="range"
|
|
42
|
-
role="slider"
|
|
43
|
-
{disabled}
|
|
44
|
-
{min}
|
|
45
|
-
{max}
|
|
46
|
-
{step}
|
|
47
|
-
aria-valuemin={min}
|
|
48
|
-
aria-valuemax={max}
|
|
49
|
-
aria-valuenow={value}
|
|
50
|
-
bind:value={real_value}
|
|
51
|
-
on:pointerdown={on_down}
|
|
52
|
-
on:change={on_change}
|
|
53
|
-
/>
|
|
54
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Theme } from "../../../typings";
|
|
3
|
+
import { createEventDispatcher } from "svelte";
|
|
4
|
+
|
|
5
|
+
const dispatch = createEventDispatcher<{ change: number }>();
|
|
6
|
+
|
|
7
|
+
let className = "";
|
|
8
|
+
export { className as class };
|
|
9
|
+
export let theme: Theme = "light";
|
|
10
|
+
export let min = 0;
|
|
11
|
+
export let max = 100;
|
|
12
|
+
export let step = 0.01;
|
|
13
|
+
export let value = 30;
|
|
14
|
+
export let disabled = false;
|
|
15
|
+
|
|
16
|
+
const name = "fastboard-slider";
|
|
17
|
+
|
|
18
|
+
let real_value = value;
|
|
19
|
+
let grabbing = false;
|
|
20
|
+
|
|
21
|
+
function on_down() {
|
|
22
|
+
grabbing = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function on_change() {
|
|
26
|
+
grabbing = false;
|
|
27
|
+
value = real_value;
|
|
28
|
+
dispatch("change", value);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
$: if (value !== real_value && !grabbing) {
|
|
32
|
+
real_value = value;
|
|
33
|
+
}
|
|
34
|
+
$: percent = (100 * (real_value - min)) / (max - min);
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<div class="{name} {className} {theme}" style="--value:{percent}%">
|
|
38
|
+
<input
|
|
39
|
+
class="{name}-track {theme}"
|
|
40
|
+
class:grabbing
|
|
41
|
+
type="range"
|
|
42
|
+
role="slider"
|
|
43
|
+
{disabled}
|
|
44
|
+
{min}
|
|
45
|
+
{max}
|
|
46
|
+
{step}
|
|
47
|
+
aria-valuemin={min}
|
|
48
|
+
aria-valuemax={max}
|
|
49
|
+
aria-valuenow={value}
|
|
50
|
+
bind:value={real_value}
|
|
51
|
+
on:pointerdown={on_down}
|
|
52
|
+
on:change={on_change}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Color, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
-
import type { Theme } from "../../../typings";
|
|
4
|
-
import { colorKeys, colors } from "./constants";
|
|
5
|
-
|
|
6
|
-
export let app: FastboardApp | null | undefined = null;
|
|
7
|
-
export let theme: Theme = "light";
|
|
8
|
-
export let disabled = false;
|
|
9
|
-
|
|
10
|
-
$: memberState = app?.memberState;
|
|
11
|
-
$: strokeColor = $memberState?.strokeColor;
|
|
12
|
-
|
|
13
|
-
function is_equal_color(a?: Color, b?: Color) {
|
|
14
|
-
return a && b && a.every((v, i) => v === b[i]);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function set_stroke_color(ev: MouseEvent) {
|
|
18
|
-
let button = ev.target as HTMLButtonElement | null;
|
|
19
|
-
if (button && button.dataset.colorKey) {
|
|
20
|
-
let color = colors[button.dataset.colorKey];
|
|
21
|
-
if (color && app) {
|
|
22
|
-
app.setStrokeColor(color);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<div class="fastboard-toolbar-colors {theme}" on:click={set_stroke_color}>
|
|
29
|
-
{#each colorKeys as key (key)}
|
|
30
|
-
<button
|
|
31
|
-
class="fastboard-toolbar-btn fastboard-toolbar-color-btn {theme}"
|
|
32
|
-
class:is-active={is_equal_color(strokeColor, colors[key])}
|
|
33
|
-
data-color-key={key}
|
|
34
|
-
{disabled}
|
|
35
|
-
>
|
|
36
|
-
<span class="fastboard-toolbar-color-item" style:background-color={key} />
|
|
37
|
-
</button>
|
|
38
|
-
{/each}
|
|
39
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Color, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import { colorKeys, colors } from "./constants";
|
|
5
|
+
|
|
6
|
+
export let app: FastboardApp | null | undefined = null;
|
|
7
|
+
export let theme: Theme = "light";
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
|
|
10
|
+
$: memberState = app?.memberState;
|
|
11
|
+
$: strokeColor = $memberState?.strokeColor;
|
|
12
|
+
|
|
13
|
+
function is_equal_color(a?: Color, b?: Color) {
|
|
14
|
+
return a && b && a.every((v, i) => v === b[i]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function set_stroke_color(ev: MouseEvent) {
|
|
18
|
+
let button = ev.target as HTMLButtonElement | null;
|
|
19
|
+
if (button && button.dataset.colorKey) {
|
|
20
|
+
let color = colors[button.dataset.colorKey];
|
|
21
|
+
if (color && app) {
|
|
22
|
+
app.setStrokeColor(color);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class="fastboard-toolbar-colors {theme}" on:click={set_stroke_color}>
|
|
29
|
+
{#each colorKeys as key (key)}
|
|
30
|
+
<button
|
|
31
|
+
class="fastboard-toolbar-btn fastboard-toolbar-color-btn {theme}"
|
|
32
|
+
class:is-active={is_equal_color(strokeColor, colors[key])}
|
|
33
|
+
data-color-key={key}
|
|
34
|
+
{disabled}
|
|
35
|
+
>
|
|
36
|
+
<span class="fastboard-toolbar-color-item" style:background-color={key} />
|
|
37
|
+
</button>
|
|
38
|
+
{/each}
|
|
39
|
+
</div>
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { FastboardApp } from "@netless/fastboard-core";
|
|
3
|
-
import type { Theme } from "../../../typings";
|
|
4
|
-
import Slider from "./Slider.svelte";
|
|
5
|
-
|
|
6
|
-
export let app: FastboardApp | null | undefined = null;
|
|
7
|
-
export let theme: Theme = "light";
|
|
8
|
-
export let disabled = false;
|
|
9
|
-
|
|
10
|
-
$: memberState = app?.memberState;
|
|
11
|
-
$: value = $memberState?.strokeWidth ?? 1;
|
|
12
|
-
|
|
13
|
-
$: props = { value, theme, disabled };
|
|
14
|
-
|
|
15
|
-
function set_stroke_width({ detail: value }: CustomEvent<number>) {
|
|
16
|
-
app?.setStrokeWidth(value);
|
|
17
|
-
}
|
|
18
|
-
</script>
|
|
19
|
-
|
|
20
|
-
<Slider class="fastboard-toolbar-slider" {...props} min={1} max={32} on:change={set_stroke_width} />
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import Slider from "./Slider.svelte";
|
|
5
|
+
|
|
6
|
+
export let app: FastboardApp | null | undefined = null;
|
|
7
|
+
export let theme: Theme = "light";
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
|
|
10
|
+
$: memberState = app?.memberState;
|
|
11
|
+
$: value = $memberState?.strokeWidth ?? 1;
|
|
12
|
+
|
|
13
|
+
$: props = { value, theme, disabled };
|
|
14
|
+
|
|
15
|
+
function set_stroke_width({ detail: value }: CustomEvent<number>) {
|
|
16
|
+
app?.setStrokeWidth(value);
|
|
17
|
+
}
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<Slider class="fastboard-toolbar-slider" {...props} min={1} max={32} on:change={set_stroke_width} />
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import type { Color, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
-
import type { Theme } from "../../../typings";
|
|
4
|
-
import { colorKeys, colors } from "./constants";
|
|
5
|
-
|
|
6
|
-
export let app: FastboardApp | null | undefined = null;
|
|
7
|
-
export let theme: Theme = "light";
|
|
8
|
-
export let disabled = false;
|
|
9
|
-
|
|
10
|
-
$: memberState = app?.memberState;
|
|
11
|
-
$: textColor = $memberState?.textColor;
|
|
12
|
-
|
|
13
|
-
function is_equal_color(a?: Color, b?: Color) {
|
|
14
|
-
return a && b && a.every((v, i) => v === b[i]);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function set_stroke_color(ev: MouseEvent) {
|
|
18
|
-
let button = ev.target as HTMLButtonElement | null;
|
|
19
|
-
if (button && button.dataset.colorKey) {
|
|
20
|
-
let color = colors[button.dataset.colorKey];
|
|
21
|
-
if (color && app) {
|
|
22
|
-
app.setTextColor(color);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
</script>
|
|
27
|
-
|
|
28
|
-
<div class="fastboard-toolbar-colors {theme}" on:click={set_stroke_color}>
|
|
29
|
-
{#each colorKeys as key (key)}
|
|
30
|
-
<button
|
|
31
|
-
class="fastboard-toolbar-btn fastboard-toolbar-color-btn {theme}"
|
|
32
|
-
class:is-active={is_equal_color(textColor, colors[key])}
|
|
33
|
-
data-color-key={key}
|
|
34
|
-
{disabled}
|
|
35
|
-
>
|
|
36
|
-
<span class="fastboard-toolbar-color-item" style:background-color={key} />
|
|
37
|
-
</button>
|
|
38
|
-
{/each}
|
|
39
|
-
</div>
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Color, FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { Theme } from "../../../typings";
|
|
4
|
+
import { colorKeys, colors } from "./constants";
|
|
5
|
+
|
|
6
|
+
export let app: FastboardApp | null | undefined = null;
|
|
7
|
+
export let theme: Theme = "light";
|
|
8
|
+
export let disabled = false;
|
|
9
|
+
|
|
10
|
+
$: memberState = app?.memberState;
|
|
11
|
+
$: textColor = $memberState?.textColor;
|
|
12
|
+
|
|
13
|
+
function is_equal_color(a?: Color, b?: Color) {
|
|
14
|
+
return a && b && a.every((v, i) => v === b[i]);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function set_stroke_color(ev: MouseEvent) {
|
|
18
|
+
let button = ev.target as HTMLButtonElement | null;
|
|
19
|
+
if (button && button.dataset.colorKey) {
|
|
20
|
+
let color = colors[button.dataset.colorKey];
|
|
21
|
+
if (color && app) {
|
|
22
|
+
app.setTextColor(color);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<div class="fastboard-toolbar-colors {theme}" on:click={set_stroke_color}>
|
|
29
|
+
{#each colorKeys as key (key)}
|
|
30
|
+
<button
|
|
31
|
+
class="fastboard-toolbar-btn fastboard-toolbar-color-btn {theme}"
|
|
32
|
+
class:is-active={is_equal_color(textColor, colors[key])}
|
|
33
|
+
data-color-key={key}
|
|
34
|
+
{disabled}
|
|
35
|
+
>
|
|
36
|
+
<span class="fastboard-toolbar-color-item" style:background-color={key} />
|
|
37
|
+
</button>
|
|
38
|
+
{/each}
|
|
39
|
+
</div>
|