@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,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>
|
|
@@ -0,0 +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>
|
|
@@ -0,0 +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} />
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Appliance, Color } from "@netless/fastboard-core";
|
|
2
|
+
import type { I18nData } from "../../../typings";
|
|
3
|
+
import Icons from "../../Icons";
|
|
4
|
+
|
|
5
|
+
export const colors: Record<string, Color> = {
|
|
6
|
+
"#E02020": [224, 32, 32],
|
|
7
|
+
"#F7B500": [247, 181, 0],
|
|
8
|
+
"#6DD400": [109, 212, 0],
|
|
9
|
+
"#32C5FF": [50, 197, 255],
|
|
10
|
+
"#0091FF": [0, 145, 255],
|
|
11
|
+
"#6236FF": [98, 54, 255],
|
|
12
|
+
"#B620E0": [182, 32, 224],
|
|
13
|
+
"#6D7278": [109, 114, 120],
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const shapes = [
|
|
17
|
+
"rectangle",
|
|
18
|
+
"ellipse",
|
|
19
|
+
"straight",
|
|
20
|
+
"arrow",
|
|
21
|
+
"pentagram",
|
|
22
|
+
"rhombus",
|
|
23
|
+
"triangle",
|
|
24
|
+
"speechBalloon",
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
export type Shape = typeof shapes[number];
|
|
28
|
+
|
|
29
|
+
export const applianceShapes = shapes.slice(0, 4) as Appliance[];
|
|
30
|
+
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
|
+
export const shapesIcon: Record<Shape, any> = {
|
|
33
|
+
rectangle: Icons.Rectangle,
|
|
34
|
+
ellipse: Icons.Circle,
|
|
35
|
+
straight: Icons.Line,
|
|
36
|
+
arrow: Icons.Arrow,
|
|
37
|
+
pentagram: Icons.Star,
|
|
38
|
+
rhombus: Icons.Rhombus,
|
|
39
|
+
triangle: Icons.Triangle,
|
|
40
|
+
speechBalloon: Icons.Balloon,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
|
+
export const shapesIconActive: Record<Shape, any> = {
|
|
45
|
+
rectangle: Icons.RectangleBolded,
|
|
46
|
+
ellipse: Icons.CircleBolded,
|
|
47
|
+
straight: Icons.LineBolded,
|
|
48
|
+
arrow: Icons.ArrowBolded,
|
|
49
|
+
pentagram: Icons.StarBolded,
|
|
50
|
+
rhombus: Icons.RhombusBolded,
|
|
51
|
+
triangle: Icons.TriangleBolded,
|
|
52
|
+
speechBalloon: Icons.BalloonBolded,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const i18n: I18nData<
|
|
56
|
+
"clicker" | "selector" | "pencil" | "text" | "shapes" | "eraser" | "clear" | "apps"
|
|
57
|
+
> = {
|
|
58
|
+
en: {
|
|
59
|
+
clicker: "clicker",
|
|
60
|
+
selector: "selector",
|
|
61
|
+
pencil: "pencil",
|
|
62
|
+
eraser: "eraser",
|
|
63
|
+
text: "text",
|
|
64
|
+
shapes: "shapes",
|
|
65
|
+
clear: "clear",
|
|
66
|
+
apps: "apps",
|
|
67
|
+
},
|
|
68
|
+
"zh-CN": {
|
|
69
|
+
clicker: "点击",
|
|
70
|
+
selector: "选择",
|
|
71
|
+
pencil: "铅笔",
|
|
72
|
+
eraser: "橡皮",
|
|
73
|
+
text: "文字",
|
|
74
|
+
shapes: "形状",
|
|
75
|
+
clear: "清屏",
|
|
76
|
+
apps: "Apps",
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const colorKeys = Object.keys(colors);
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { HotKey } from "@netless/fastboard-core";
|
|
2
|
+
import { element, attr, append } from "svelte/internal";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ```svelte
|
|
6
|
+
* <span class="fastboard-toolbar-tooltip">
|
|
7
|
+
* <span>{text}</span>
|
|
8
|
+
* <span class="fastboard-toolbar-hotkey">{hotkey.toUpperCase()}</span>
|
|
9
|
+
* </span>
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export function tooltip(text: string, hotkey?: HotKey) {
|
|
13
|
+
if (!hotkey || typeof hotkey !== "string") return text;
|
|
14
|
+
const outer = element("span");
|
|
15
|
+
const inner = element("span");
|
|
16
|
+
inner.textContent = text;
|
|
17
|
+
const hotkey_span = element("span");
|
|
18
|
+
hotkey_span.textContent = hotkey.toUpperCase();
|
|
19
|
+
attr(outer, "class", "fastboard-toolbar-tooltip");
|
|
20
|
+
attr(hotkey_span, "class", "fastboard-toolbar-hotkey");
|
|
21
|
+
append(outer, inner);
|
|
22
|
+
append(outer, hotkey_span);
|
|
23
|
+
return outer;
|
|
24
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<script lang="ts" context="module">
|
|
2
|
+
import type { FastboardApp } from "@netless/fastboard-core";
|
|
3
|
+
import type { GenericIcon, I18nData, IconType, Language, Theme } from "../../typings";
|
|
4
|
+
import { clamp } from "../helpers";
|
|
5
|
+
|
|
6
|
+
const i18n: I18nData<"plus" | "minus" | "reset"> = {
|
|
7
|
+
en: {
|
|
8
|
+
plus: "Zoom In",
|
|
9
|
+
minus: "Zoom Out",
|
|
10
|
+
reset: "Reset",
|
|
11
|
+
},
|
|
12
|
+
"zh-CN": {
|
|
13
|
+
plus: "放大",
|
|
14
|
+
minus: "缩小",
|
|
15
|
+
reset: "重置",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const scales: readonly number[] = [
|
|
20
|
+
0.3, 0.4096000000000002, 0.5120000000000001, 0.6400000000000001, 0.8, 1, 1.26, 1.5876000000000001,
|
|
21
|
+
2.000376, 2.5204737600000002, 3,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
function next_scale(scale: number, delta: 1 | -1) {
|
|
25
|
+
const { length } = scales;
|
|
26
|
+
const last = length - 1;
|
|
27
|
+
if (scale < scales[0]) return scales[0];
|
|
28
|
+
if (scale > scales[last]) return scales[last];
|
|
29
|
+
for (let i = 0; i < length; ++i) {
|
|
30
|
+
const cur = scales[i];
|
|
31
|
+
const prev = i === 0 ? -Infinity : (scales[i - 1] + cur) / 2;
|
|
32
|
+
const next = i === last ? Infinity : (scales[i + 1] + cur) / 2;
|
|
33
|
+
if (prev <= scale && scale <= next) return scales[clamp(i + delta, 0, last)];
|
|
34
|
+
}
|
|
35
|
+
return 1;
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<script lang="ts">
|
|
40
|
+
import Icon from "../Icon";
|
|
41
|
+
import Icons from "../Icons";
|
|
42
|
+
import Button from "../Button";
|
|
43
|
+
|
|
44
|
+
export let app: FastboardApp | null | undefined = null;
|
|
45
|
+
export let theme: Theme = "light";
|
|
46
|
+
export let language: Language = "en";
|
|
47
|
+
export let icons: GenericIcon<"plus" | "minus" | "reset"> | undefined = undefined;
|
|
48
|
+
|
|
49
|
+
const name = "fastboard-zoom-control";
|
|
50
|
+
|
|
51
|
+
$: writable = app?.writable;
|
|
52
|
+
$: disabled = !$writable;
|
|
53
|
+
$: t = i18n[language];
|
|
54
|
+
|
|
55
|
+
let type: IconType;
|
|
56
|
+
$: type = disabled ? "disable" : "normal";
|
|
57
|
+
|
|
58
|
+
$: camera = app?.camera;
|
|
59
|
+
$: scale = $camera?.scale ?? 1;
|
|
60
|
+
$: plus_disabled = disabled || next_scale(scale, 1) === scale;
|
|
61
|
+
$: minus_disabled = disabled || next_scale(scale, -1) === scale;
|
|
62
|
+
|
|
63
|
+
function plus() {
|
|
64
|
+
app?.moveCamera({ scale: next_scale(scale, 1), centerX: 0, centerY: 0 });
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function minus() {
|
|
68
|
+
app?.moveCamera({ scale: next_scale(scale, -1), centerX: 0, centerY: 0 });
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function reset() {
|
|
72
|
+
app?.moveCamera({ scale: 1, centerX: 0, centerY: 0 });
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<div class="{name} {theme}">
|
|
77
|
+
<Button class="plus" {name} {theme} disabled={plus_disabled} on:click={plus} content={t.plus}>
|
|
78
|
+
<Icon src={icons?.plus[type]} alt="[plus]">
|
|
79
|
+
<Icons.Plus {theme} />
|
|
80
|
+
</Icon>
|
|
81
|
+
</Button>
|
|
82
|
+
<span class="{name}-text {theme}">
|
|
83
|
+
{#if $camera == null}
|
|
84
|
+
…
|
|
85
|
+
{:else}
|
|
86
|
+
{Math.ceil(scale * 100)}%
|
|
87
|
+
{/if}
|
|
88
|
+
</span>
|
|
89
|
+
<Button class="minus" {name} {theme} disabled={minus_disabled} on:click={minus} content={t.minus}>
|
|
90
|
+
<Icon src={icons?.minus[type]} alt="[minus]">
|
|
91
|
+
<Icons.Minus {theme} />
|
|
92
|
+
</Icon>
|
|
93
|
+
</Button>
|
|
94
|
+
<Button class="reset" {name} {theme} {disabled} on:click={reset} content={t.reset}>
|
|
95
|
+
<Icon src={icons?.reset[type]} alt="[reset]">
|
|
96
|
+
<Icons.Reset {theme} />
|
|
97
|
+
</Icon>
|
|
98
|
+
</Button>
|
|
99
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { FastboardApp } from "@netless/fastboard-core";
|
|
2
|
+
import type { Theme, Language, GenericIcon } from "../../typings";
|
|
3
|
+
import { SvelteComponentTyped } from "svelte";
|
|
4
|
+
|
|
5
|
+
export declare interface ZoomControlProps {
|
|
6
|
+
app?: FastboardApp | null;
|
|
7
|
+
theme?: Theme;
|
|
8
|
+
language?: Language;
|
|
9
|
+
icons?: GenericIcon<"plus" | "minus" | "reset">;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare class ZoomControl extends SvelteComponentTyped<ZoomControlProps> {}
|
|
13
|
+
export default ZoomControl;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
@use "sass:color";
|
|
2
|
+
@import "./variables.scss";
|
|
3
|
+
|
|
4
|
+
$themes: (
|
|
5
|
+
light: (
|
|
6
|
+
color: $grey-6,
|
|
7
|
+
active-color: $blue-6,
|
|
8
|
+
bg-color: color.change(white, $alpha: 0.9),
|
|
9
|
+
hover-bg-color: $blue-1,
|
|
10
|
+
border-color: $grey-1,
|
|
11
|
+
),
|
|
12
|
+
dark: (
|
|
13
|
+
color: $grey-5,
|
|
14
|
+
active-color: $blue-7,
|
|
15
|
+
bg-color: color.change($grey-10, $alpha: 0.9),
|
|
16
|
+
hover-bg-color: $grey-8,
|
|
17
|
+
border-color: $grey-8,
|
|
18
|
+
),
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
@function read($theme, $name) {
|
|
22
|
+
@return var(--fastboard-#{$name}, map-get($theme, $name));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@mixin border-box {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
|
|
28
|
+
* {
|
|
29
|
+
box-sizing: inherit;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@mixin tabular-nums {
|
|
34
|
+
font-variant-numeric: tabular-nums;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@mixin container {
|
|
38
|
+
@include border-box;
|
|
39
|
+
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 4px;
|
|
43
|
+
padding: 4px;
|
|
44
|
+
border: 1px solid;
|
|
45
|
+
border-radius: 4px;
|
|
46
|
+
font-size: 14px;
|
|
47
|
+
font-family: system-ui;
|
|
48
|
+
backdrop-filter: blur(5px);
|
|
49
|
+
-webkit-backdrop-filter: blur(5px);
|
|
50
|
+
|
|
51
|
+
@each $name, $theme in $themes {
|
|
52
|
+
&.#{$name} {
|
|
53
|
+
color: read($theme, "color");
|
|
54
|
+
background-color: read($theme, "bg-color");
|
|
55
|
+
border-color: read($theme, "border-color");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@mixin btn($size: 24px, $padding: 0) {
|
|
61
|
+
appearance: none;
|
|
62
|
+
cursor: pointer;
|
|
63
|
+
margin: 0;
|
|
64
|
+
border: 0;
|
|
65
|
+
padding: $padding;
|
|
66
|
+
width: $size;
|
|
67
|
+
height: $size;
|
|
68
|
+
background-color: transparent;
|
|
69
|
+
border-radius: 4px;
|
|
70
|
+
font-size: 0;
|
|
71
|
+
line-height: 1;
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
|
|
74
|
+
svg,
|
|
75
|
+
img {
|
|
76
|
+
width: 100%;
|
|
77
|
+
height: 100%;
|
|
78
|
+
pointer-events: none;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
&:disabled {
|
|
82
|
+
opacity: 0.5;
|
|
83
|
+
cursor: not-allowed;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@each $name, $theme in $themes {
|
|
87
|
+
&.#{$name}:not(:disabled):hover {
|
|
88
|
+
background-color: read($theme, "hover-bg-color");
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
$blue-0: #f4f8ff;
|
|
2
|
+
$blue-1: #ebf2ff;
|
|
3
|
+
$blue-2: #d6e5ff;
|
|
4
|
+
$blue-3: #adccff;
|
|
5
|
+
$blue-4: #84b3ff;
|
|
6
|
+
$blue-5: #5b9aff;
|
|
7
|
+
$blue-6: #3381ff;
|
|
8
|
+
$blue-7: #2867cc;
|
|
9
|
+
$blue-8: #1e4d99;
|
|
10
|
+
$blue-9: #143366;
|
|
11
|
+
$blue-10: #0a1933;
|
|
12
|
+
$blue-11: #050d1a;
|
|
13
|
+
$blue-12: #03060d;
|
|
14
|
+
|
|
15
|
+
$grey-0: #ecf0f7;
|
|
16
|
+
$grey-1: #e5e8f0;
|
|
17
|
+
$grey-2: #d5d9e0;
|
|
18
|
+
$grey-3: #b7bbc1;
|
|
19
|
+
$grey-4: #999ca3;
|
|
20
|
+
$grey-5: #7b7e84;
|
|
21
|
+
$grey-6: #5d6066;
|
|
22
|
+
$grey-7: #4b4d54;
|
|
23
|
+
$grey-8: #383b42;
|
|
24
|
+
$grey-9: #272a30;
|
|
25
|
+
$grey-10: #14181e;
|
|
26
|
+
$grey-11: #070a11;
|
|
27
|
+
$grey-12: #03060d;
|
|
28
|
+
|
|
29
|
+
$green-0: #f5faf2;
|
|
30
|
+
$green-1: #ecf6e6;
|
|
31
|
+
$green-2: #d9eecc;
|
|
32
|
+
$green-3: #b4de99;
|
|
33
|
+
$green-4: #8ecd66;
|
|
34
|
+
$green-5: #69bd33;
|
|
35
|
+
$green-6: #44ad00;
|
|
36
|
+
$green-7: #368b00;
|
|
37
|
+
$green-8: #296800;
|
|
38
|
+
$green-9: #1b4500;
|
|
39
|
+
$green-10: #0d2200;
|
|
40
|
+
$green-11: #071100;
|
|
41
|
+
$green-12: #030900;
|
|
42
|
+
|
|
43
|
+
$yellow-0: #fdf9f2;
|
|
44
|
+
$yellow-1: #fcf4e6;
|
|
45
|
+
$yellow-2: #faeacc;
|
|
46
|
+
$yellow-3: #f5d599;
|
|
47
|
+
$yellow-4: #f1c166;
|
|
48
|
+
$yellow-5: #ecac33;
|
|
49
|
+
$yellow-6: #e89800;
|
|
50
|
+
$yellow-7: #ba7a00;
|
|
51
|
+
$yellow-8: #8b5b00;
|
|
52
|
+
$yellow-9: #5c3c00;
|
|
53
|
+
$yellow-10: #2e1e00;
|
|
54
|
+
$yellow-11: #170f00;
|
|
55
|
+
$yellow-12: #0c0800;
|
|
56
|
+
|
|
57
|
+
$red-0: #fcf3f2;
|
|
58
|
+
$red-1: #fae9e6;
|
|
59
|
+
$red-2: #f6d2cc;
|
|
60
|
+
$red-3: #eda599;
|
|
61
|
+
$red-4: #e47866;
|
|
62
|
+
$red-5: #db4b33;
|
|
63
|
+
$red-6: #d21f00;
|
|
64
|
+
$red-7: #a81800;
|
|
65
|
+
$red-8: #7e1300;
|
|
66
|
+
$red-9: #540c00;
|
|
67
|
+
$red-10: #2a0600;
|
|
68
|
+
$red-11: #150300;
|
|
69
|
+
$red-12: #0a0200;
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { GenericIcon, Language, Theme } from "./typings";
|
|
2
|
+
|
|
3
|
+
export { default as RedoUndo, type RedoUndoProps } from "./components/RedoUndo";
|
|
4
|
+
export { default as PageControl, type PageControlProps } from "./components/PageControl";
|
|
5
|
+
export { default as ZoomControl, type ZoomControlProps } from "./components/ZoomControl";
|
|
6
|
+
export { default as Toolbar, type ToolbarProps } from "./components/Toolbar";
|
|
7
|
+
export { default as PlayerControl, type PlayerControlProps } from "./components/PlayerControl";
|
|
8
|
+
export { Fastboard, ReplayFastboard } from "./components/Fastboard";
|
|
9
|
+
export type { FastboardProps, ReplayFastboardProps } from "./components/Fastboard";
|
|
10
|
+
|
|
11
|
+
export * from "./behaviors";
|
|
12
|
+
|
|
13
|
+
import "./style.scss";
|
package/src/style.scss
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
@import "./components/theme.scss";
|
|
2
|
+
|
|
3
|
+
@import "tippy.js/dist/tippy.css";
|
|
4
|
+
@import "tippy.js/themes/light.css";
|
|
5
|
+
|
|
6
|
+
@import "./components/Icons/Icons.scss";
|
|
7
|
+
@import "./components/RedoUndo/RedoUndo.scss";
|
|
8
|
+
@import "./components/ZoomControl/ZoomControl.scss";
|
|
9
|
+
@import "./components/PageControl/PageControl.scss";
|
|
10
|
+
@import "./components/PlayerControl/PlayerControl.scss";
|
|
11
|
+
@import "./components/Toolbar/Toolbar.scss";
|
|
12
|
+
@import "./components/Fastboard/Fastboard.scss";
|
|
13
|
+
|
|
14
|
+
.fastboard-tip {
|
|
15
|
+
font-family: inherit;
|
|
16
|
+
color: $grey-2;
|
|
17
|
+
background-color: $grey-12;
|
|
18
|
+
|
|
19
|
+
&[data-placement^="right"] > .tippy-arrow::before {
|
|
20
|
+
top: 4px;
|
|
21
|
+
border-width: 4px;
|
|
22
|
+
border-right-color: $grey-12;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
&[data-placement^="top"] > .tippy-arrow::before {
|
|
26
|
+
left: 4px;
|
|
27
|
+
border-width: 4px;
|
|
28
|
+
border-top-color: $grey-12;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.fastboard-panel {
|
|
33
|
+
.tippy-content {
|
|
34
|
+
padding: 8px;
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/typings.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export interface SvelteAction<T = void> {
|
|
2
|
+
(node: HTMLElement, parameters: T): void | {
|
|
3
|
+
update?: (parameters: T) => void;
|
|
4
|
+
destroy?: () => void;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type Theme = "light" | "dark";
|
|
9
|
+
|
|
10
|
+
export type Language = "en" | "zh-CN";
|
|
11
|
+
|
|
12
|
+
export type IconType = "normal" | "disable";
|
|
13
|
+
export type GenericIcon<K extends string, E extends string = IconType> = {
|
|
14
|
+
[key in K]: { [kind in E]: string };
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type I18nData<T extends string> = Record<Language, Record<T, string>>;
|