@netless/fastboard-ui 0.3.2-canary.3 → 0.3.2-canary.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -2
- package/dist/index.js +535 -302
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +535 -302
- package/dist/index.mjs.map +1 -1
- package/dist/index.svelte.mjs +954 -703
- package/dist/index.svelte.mjs.map +1 -1
- package/package.json +3 -3
- package/src/behaviors/apps.ts +4 -0
- package/src/components/Fastboard/Fastboard.svelte +1 -1
- package/src/components/Toolbar/Toolbar.svelte +14 -2
- package/src/components/Toolbar/Toolbar.svelte.d.ts +2 -1
- package/src/components/Toolbar/components/Contents.svelte +8 -4
- package/src/components/Toolbar/components/TextColor.svelte +39 -0
- package/src/typings.ts +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netless/fastboard-ui",
|
|
3
|
-
"version": "0.3.2-canary.
|
|
3
|
+
"version": "0.3.2-canary.6",
|
|
4
4
|
"description": "The front-end of @netless/fastboard-core.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"svelte": "dist/index.svelte.mjs",
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
],
|
|
11
11
|
"repository": "netless-io/fastboard",
|
|
12
12
|
"peerDependencies": {
|
|
13
|
-
"@netless/fastboard-core": "0.3.2-canary.
|
|
13
|
+
"@netless/fastboard-core": "0.3.2-canary.6"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"tippy.js": "^6.3.7"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@netless/esbuild-plugin-inline-sass": "0.1.0",
|
|
20
|
-
"@netless/fastboard-core": "0.3.2-canary.
|
|
20
|
+
"@netless/fastboard-core": "0.3.2-canary.6"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"cleanup": "rimraf dist",
|
package/src/behaviors/apps.ts
CHANGED
|
@@ -38,6 +38,10 @@ class AppsInToolbar {
|
|
|
38
38
|
this._data = this._data.filter(item => !filter(item));
|
|
39
39
|
this._listeners.forEach(fn => fn(this._data));
|
|
40
40
|
}
|
|
41
|
+
clear() {
|
|
42
|
+
this._data.length = 0;
|
|
43
|
+
this._listeners.forEach(fn => fn(this._data));
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
export type { AppsInToolbar };
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
<div class="{name}-view" bind:this={container} on:touchstart|capture={tippy_hide_all} />
|
|
62
62
|
<div class="{name}-left" class:hidden={!(layout === "visible" || layout === "toolbar-only")}>
|
|
63
63
|
{#if config.toolbar?.enable !== false}
|
|
64
|
-
<Toolbar {app} {theme} {language} />
|
|
64
|
+
<Toolbar {app} {theme} {language} config={config.toolbar} />
|
|
65
65
|
{/if}
|
|
66
66
|
</div>
|
|
67
67
|
<div class="{name}-bottom-left" class:hidden={layout !== "visible"}>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { FastboardApp } from "@netless/fastboard-core";
|
|
3
|
-
import type { Language, Theme } from "../../typings";
|
|
3
|
+
import type { Language, Theme, ToolbarConfig } from "../../typings";
|
|
4
4
|
import { writable as svelte_writable } from "svelte/store";
|
|
5
5
|
import { height } from "../../actions/height";
|
|
6
6
|
import { clamp } from "../helpers";
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export let app: FastboardApp | null | undefined = null;
|
|
10
10
|
export let theme: Theme = "light";
|
|
11
11
|
export let language: Language = "en";
|
|
12
|
+
export let config: ToolbarConfig = {};
|
|
12
13
|
|
|
13
14
|
const name = "fastboard-toolbar";
|
|
14
15
|
const extra_height = (32 + 4 + 4) * 2;
|
|
@@ -22,11 +23,22 @@
|
|
|
22
23
|
|
|
23
24
|
$: computed_height = clamp($container_height, extra_height, $scroll_height + extra_height);
|
|
24
25
|
$: scrollable = $scroll_height + extra_height > $container_height;
|
|
26
|
+
|
|
27
|
+
$: hide_apps = config.apps?.enable === false;
|
|
25
28
|
</script>
|
|
26
29
|
|
|
27
30
|
<div class="{name} {theme}" class:collapsed use:height={container_height}>
|
|
28
31
|
<div class="{name}-contents {theme}" style:height={scrollable ? computed_height + "px" : "auto"}>
|
|
29
|
-
<Contents
|
|
32
|
+
<Contents
|
|
33
|
+
{app}
|
|
34
|
+
{theme}
|
|
35
|
+
{language}
|
|
36
|
+
{disabled}
|
|
37
|
+
{scroll_height}
|
|
38
|
+
{computed_height}
|
|
39
|
+
{scrollable}
|
|
40
|
+
{hide_apps}
|
|
41
|
+
/>
|
|
30
42
|
</div>
|
|
31
43
|
<label class="{name}-handler {theme}">
|
|
32
44
|
<input type="checkbox" bind:checked={collapsed} />
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { FastboardApp } from "@netless/fastboard-core";
|
|
2
|
-
import type { Theme, Language } from "../../typings";
|
|
2
|
+
import type { Theme, Language, ToolbarConfig } from "../../typings";
|
|
3
3
|
import { SvelteComponentTyped } from "svelte";
|
|
4
4
|
|
|
5
5
|
export declare interface ToolbarProps {
|
|
6
6
|
app?: FastboardApp | null;
|
|
7
7
|
theme?: Theme;
|
|
8
8
|
language?: Language;
|
|
9
|
+
config?: ToolbarConfig;
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
declare class Toolbar extends SvelteComponentTyped<ToolbarProps> {}
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import Button from "../../Button";
|
|
17
17
|
import StrokeWidth from "./StrokeWidth.svelte";
|
|
18
18
|
import StrokeColor from "./StrokeColor.svelte";
|
|
19
|
+
import TextColor from "./TextColor.svelte";
|
|
19
20
|
import Shapes from "./Shapes.svelte";
|
|
20
21
|
|
|
21
22
|
export let app: FastboardApp | null | undefined = null;
|
|
@@ -25,6 +26,7 @@
|
|
|
25
26
|
export let scroll_height: Writable<number>;
|
|
26
27
|
export let computed_height = 0;
|
|
27
28
|
export let scrollable = false;
|
|
29
|
+
export let hide_apps = false;
|
|
28
30
|
|
|
29
31
|
const name = "fastboard-toolbar";
|
|
30
32
|
|
|
@@ -146,9 +148,11 @@
|
|
|
146
148
|
<Button class="clear" {...btn_props} on:click={clear} content={t.clear}>
|
|
147
149
|
<Icons.Clear {theme} />
|
|
148
150
|
</Button>
|
|
149
|
-
|
|
150
|
-
<
|
|
151
|
-
|
|
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}
|
|
152
156
|
</div>
|
|
153
157
|
{#if scrollable}
|
|
154
158
|
<Button class="scroll-down" {name} {theme} {disabled} on:click={scroll_down}>
|
|
@@ -163,7 +167,7 @@
|
|
|
163
167
|
<StrokeColor {app} {theme} {disabled} />
|
|
164
168
|
</div>
|
|
165
169
|
<div class="{name}-panel text" bind:this={text_panel}>
|
|
166
|
-
<
|
|
170
|
+
<TextColor {app} {theme} {disabled} />
|
|
167
171
|
</div>
|
|
168
172
|
<div class="{name}-panel shapes" bind:this={shapes_panel}>
|
|
169
173
|
<Shapes {app} {theme} {language} {disabled} />
|
|
@@ -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
|
+
$: 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>
|
package/src/typings.ts
CHANGED
|
@@ -16,10 +16,16 @@ export type GenericIcon<K extends string, E extends string = IconType> = {
|
|
|
16
16
|
|
|
17
17
|
export type I18nData<T extends string> = Record<Language, Record<T, string>>;
|
|
18
18
|
|
|
19
|
+
export interface ToolbarConfig {
|
|
20
|
+
apps?: {
|
|
21
|
+
enable?: boolean;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
19
25
|
export interface FastboardUIConfig {
|
|
20
26
|
toolbar?: {
|
|
21
27
|
enable?: boolean;
|
|
22
|
-
};
|
|
28
|
+
} & ToolbarConfig;
|
|
23
29
|
redo_undo?: {
|
|
24
30
|
enable?: boolean;
|
|
25
31
|
};
|