@netless/fastboard-ui 0.3.2-canary.1 → 0.3.2-canary.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netless/fastboard-ui",
3
- "version": "0.3.2-canary.1",
3
+ "version": "0.3.2-canary.4",
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.1"
13
+ "@netless/fastboard-core": "0.3.2-canary.4"
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.1"
20
+ "@netless/fastboard-core": "0.3.2-canary.4"
21
21
  },
22
22
  "scripts": {
23
23
  "cleanup": "rimraf dist",
@@ -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, FastboardUIConfig } from "../../typings";
4
4
  import { onMount } from "svelte";
5
5
  import { tippy_hide_all } from "../../actions/tippy";
6
6
  import RedoUndo from "../RedoUndo";
@@ -12,6 +12,7 @@
12
12
  export let theme: Theme = "light";
13
13
  export let language: Language = "en";
14
14
  export let containerRef: ((element: HTMLDivElement | null) => void) | undefined = undefined;
15
+ export let config: FastboardUIConfig = {};
15
16
 
16
17
  const name = "fastboard";
17
18
  const AppsShowToolbar = ["DocsViewer", "Slide"];
@@ -59,13 +60,21 @@
59
60
  <div class="{name}-root" class:loading={!app}>
60
61
  <div class="{name}-view" bind:this={container} on:touchstart|capture={tippy_hide_all} />
61
62
  <div class="{name}-left" class:hidden={!(layout === "visible" || layout === "toolbar-only")}>
62
- <Toolbar {app} {theme} {language} />
63
+ {#if config.toolbar?.enable !== false}
64
+ <Toolbar {app} {theme} {language} />
65
+ {/if}
63
66
  </div>
64
67
  <div class="{name}-bottom-left" class:hidden={layout !== "visible"}>
65
- <RedoUndo {app} {theme} {language} />
66
- <ZoomControl {app} {theme} {language} />
68
+ {#if config.redo_undo?.enable !== false}
69
+ <RedoUndo {app} {theme} {language} />
70
+ {/if}
71
+ {#if config.zoom_control?.enable !== false}
72
+ <ZoomControl {app} {theme} {language} />
73
+ {/if}
67
74
  </div>
68
75
  <div class="{name}-bottom-right" class:hidden={layout !== "visible"}>
69
- <PageControl {app} {theme} {language} />
76
+ {#if config.page_control?.enable !== false}
77
+ <PageControl {app} {theme} {language} />
78
+ {/if}
70
79
  </div>
71
80
  </div>
@@ -1,5 +1,5 @@
1
1
  import type { FastboardApp } from "@netless/fastboard-core";
2
- import type { Theme, Language } from "../../typings";
2
+ import type { Theme, Language, FastboardUIConfig } from "../../typings";
3
3
  import { SvelteComponentTyped } from "svelte";
4
4
 
5
5
  export declare interface FastboardProps {
@@ -7,6 +7,7 @@ export declare interface FastboardProps {
7
7
  theme?: Theme;
8
8
  language?: Language;
9
9
  containerRef?: (container: HTMLDivElement | null) => void;
10
+ config?: FastboardUIConfig;
10
11
  }
11
12
 
12
13
  declare class Fastboard extends SvelteComponentTyped<FastboardProps> {}
@@ -21,9 +21,14 @@ $name: "fastboard-toolbar";
21
21
  left: 100%;
22
22
  width: 17px;
23
23
  font-size: 0;
24
+ border-radius: 3px;
24
25
  cursor: pointer;
25
26
  pointer-events: auto;
26
27
 
28
+ &:focus-within {
29
+ outline: 2px solid -webkit-focus-ring-color;
30
+ }
31
+
27
32
  input[type="checkbox"] {
28
33
  position: absolute;
29
34
  top: 0;
@@ -33,6 +38,8 @@ $name: "fastboard-toolbar";
33
38
  width: 100%;
34
39
  height: 100%;
35
40
  cursor: pointer;
41
+ opacity: 0;
42
+ z-index: -1;
36
43
  }
37
44
 
38
45
  svg {
@@ -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;
@@ -163,7 +164,7 @@
163
164
  <StrokeColor {app} {theme} {disabled} />
164
165
  </div>
165
166
  <div class="{name}-panel text" bind:this={text_panel}>
166
- <StrokeColor {app} {theme} {disabled} />
167
+ <TextColor {app} {theme} {disabled} />
167
168
  </div>
168
169
  <div class="{name}-panel shapes" bind:this={shapes_panel}>
169
170
  <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/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { GenericIcon, Language, Theme } from "./typings";
1
+ export * from "./typings";
2
2
 
3
3
  export { default as RedoUndo, type RedoUndoProps } from "./components/RedoUndo";
4
4
  export { default as PageControl, type PageControlProps } from "./components/PageControl";
package/src/typings.ts CHANGED
@@ -15,3 +15,18 @@ export type GenericIcon<K extends string, E extends string = IconType> = {
15
15
  };
16
16
 
17
17
  export type I18nData<T extends string> = Record<Language, Record<T, string>>;
18
+
19
+ export interface FastboardUIConfig {
20
+ toolbar?: {
21
+ enable?: boolean;
22
+ };
23
+ redo_undo?: {
24
+ enable?: boolean;
25
+ };
26
+ zoom_control?: {
27
+ enable?: boolean;
28
+ };
29
+ page_control?: {
30
+ enable?: boolean;
31
+ };
32
+ }