@netless/fastboard-react 0.2.5 → 0.2.8

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.
@@ -55,8 +55,10 @@ export function ZoomControl({
55
55
  />
56
56
  </button>
57
57
  </Tippy>
58
- <span className={clsx(`${name}-scale`, theme)}>{Math.ceil(scale * 100)}</span>
59
- <span className={clsx(`${name}-percent`, theme)}>%</span>
58
+ <span className={clsx(`${name}-text`, theme)}>
59
+ <span className={clsx(`${name}-scale`, theme)}>{Math.ceil(scale * 100)}</span>
60
+ <span className={clsx(`${name}-percent`, theme)}>%</span>
61
+ </span>
60
62
  <Tippy
61
63
  className="fastboard-tip"
62
64
  content={t("zoomIn")}
@@ -4,10 +4,8 @@ import { clamp } from "../../internal";
4
4
  import { useFastboardApp, useFastboardValue } from "../hooks";
5
5
 
6
6
  export const ScalePoints: readonly number[] = [
7
- 0.10737418240000011, 0.13421772800000012, 0.16777216000000014, 0.20971520000000016, 0.26214400000000015,
8
- 0.3276800000000002, 0.4096000000000002, 0.5120000000000001, 0.6400000000000001, 0.8, 1, 1.26,
9
- 1.5876000000000001, 2.000376, 2.5204737600000002, 3.1757969376000004, 4.001504141376, 5.041895218133761,
10
- 6.352787974848539, 8.00451284830916, 10,
7
+ 0.3, 0.4096000000000002, 0.5120000000000001, 0.6400000000000001, 0.8, 1, 1.26, 1.5876000000000001, 2.000376,
8
+ 2.5204737600000002, 3,
11
9
  ];
12
10
 
13
11
  function nextScale(scale: number, delta: 1 | -1) {
@@ -0,0 +1,15 @@
1
+ import type { IconProps } from "../typings";
2
+
3
+ import React from "react";
4
+ import { themes } from "../theme";
5
+
6
+ export function Left({ theme = "light", active }: IconProps) {
7
+ const config = themes[theme];
8
+ const stroke = active ? config.activeColor : config.color;
9
+
10
+ return (
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path d="m14 8-2 2-2 2 2 2 2 2" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
13
+ </svg>
14
+ );
15
+ }
@@ -8,8 +8,8 @@ export function Minus({ theme = "light", active }: IconProps) {
8
8
  const stroke = active ? config.activeColor : config.color;
9
9
 
10
10
  return (
11
- <svg viewBox="0 0 24 24">
12
- <path fill="none" stroke={stroke} strokeLinecap="round" strokeLinejoin="round" d="M7 12h10" />
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path d="M5 12h14" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
13
13
  </svg>
14
14
  );
15
15
  }
@@ -8,8 +8,8 @@ export function Plus({ theme = "light", active }: IconProps) {
8
8
  const stroke = active ? config.activeColor : config.color;
9
9
 
10
10
  return (
11
- <svg viewBox="0 0 24 24">
12
- <path fill="none" stroke={stroke} strokeLinecap="round" strokeLinejoin="round" d="M12 7v10m-5-5h10" />
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path d="M5 12h14m-7-7v14" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
13
13
  </svg>
14
14
  );
15
15
  }
@@ -8,11 +8,12 @@ export function Redo({ theme = "light", active }: IconProps) {
8
8
  const stroke = active ? config.activeColor : config.color;
9
9
 
10
10
  return (
11
- <svg viewBox="0 0 24 24">
12
- <g fill="none" fillRule="evenodd" stroke={stroke} strokeLinecap="round" strokeLinejoin="round">
13
- <path d="M14 14h4v-4" />
14
- <path d="m18 14-.788-.9A7.005 7.005 0 0 0 6 14h0" />
15
- </g>
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path
13
+ d="M19 9.625H9v-1.25h10v1.25ZM5.625 13v6h-1.25v-6h1.25ZM9 9.625A3.375 3.375 0 0 0 5.625 13h-1.25A4.625 4.625 0 0 1 9 8.375v1.25Z"
14
+ fill={stroke}
15
+ />
16
+ <path d="m15 5 4 4-4 4" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
16
17
  </svg>
17
18
  );
18
19
  }
@@ -8,12 +8,10 @@ export function Reset({ theme = "light", active }: IconProps) {
8
8
  const stroke = active ? config.activeColor : config.color;
9
9
 
10
10
  return (
11
- <svg viewBox="0 0 24 24">
12
- <g fill="none" fillRule="evenodd" transform="translate(-176 -684)">
13
- <path stroke={stroke} strokeLinejoin="round" d="M188 688v4m0 8v4m8-8h-4m-8 0h-4" />
14
- <circle cx="188" cy="696" r="6" stroke={stroke} />
15
- <circle cx="188" cy="696" r="1" fill={stroke} />
16
- </g>
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <circle cx="12" cy="12" fill={stroke} r="2" />
13
+ <path d="M12 3v4m0 10v4m9-9h-4M7 12H3" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
14
+ <circle cx="12" cy="12" r="7" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
17
15
  </svg>
18
16
  );
19
17
  }
@@ -0,0 +1,15 @@
1
+ import type { IconProps } from "../typings";
2
+
3
+ import React from "react";
4
+ import { themes } from "../theme";
5
+
6
+ export function Right({ theme = "light", active }: IconProps) {
7
+ const config = themes[theme];
8
+ const stroke = active ? config.activeColor : config.color;
9
+
10
+ return (
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path d="m10 8 2 2 2 2-2 2-2 2" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
13
+ </svg>
14
+ );
15
+ }
@@ -8,11 +8,12 @@ export function Undo({ theme = "light", active }: IconProps) {
8
8
  const stroke = active ? config.activeColor : config.color;
9
9
 
10
10
  return (
11
- <svg viewBox="0 0 24 24">
12
- <g fill="none" fillRule="evenodd" stroke={stroke} strokeLinecap="round" strokeLinejoin="round">
13
- <path d="M10 14H6v-4" />
14
- <path d="m6 14 .788-.9A7.005 7.005 0 0 1 18 14h0" />
15
- </g>
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path
13
+ d="M5 9.625h10v-1.25H5v1.25ZM18.375 13v6h1.25v-6h-1.25ZM15 9.625A3.375 3.375 0 0 1 18.375 13h1.25A4.625 4.625 0 0 0 15 8.375v1.25Z"
14
+ fill={stroke}
15
+ />
16
+ <path d="M9 5 5 9l4 4" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
16
17
  </svg>
17
18
  );
18
19
  }
@@ -0,0 +1,26 @@
1
+ import type { IconProps } from "../typings";
2
+
3
+ import React from "react";
4
+ import { themes } from "../theme";
5
+
6
+ export function WhiteboardAdd({ theme = "light", active }: IconProps) {
7
+ const config = themes[theme];
8
+ const stroke = active ? config.activeColor : config.color;
9
+
10
+ return (
11
+ <svg viewBox="0 0 24 24" fill="none">
12
+ <path d="M4 20h16M4 6h16" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
13
+ <rect
14
+ height="10"
15
+ rx="1"
16
+ stroke={stroke}
17
+ strokeLinejoin="round"
18
+ strokeWidth="1.25"
19
+ width="14"
20
+ x="5"
21
+ y="8"
22
+ />
23
+ <path d="M12 4v2m-3 7h6m-3-3v6" stroke={stroke} strokeLinejoin="round" strokeWidth="1.25" />
24
+ </svg>
25
+ );
26
+ }
@@ -5,14 +5,24 @@ import React from "react";
5
5
  import ReactDOM from "react-dom";
6
6
  import { Fastboard } from "../components/Fastboard";
7
7
 
8
+ export type MountProps = Omit<FastboardProps & DivProps, "ref">;
9
+
8
10
  /**
9
11
  * Mount fastboard app to some dom, returns the disposer, which will unmount the app.
10
12
  * @example
11
13
  * let app = await createFastboard({ ...config })
12
- * let disposer = mount(app, document.getElementById("whiteboard"))
13
- * disposer()
14
+ * const { update, destroy } = mount(app, document.getElementById("whiteboard"))
15
+ * update({ theme: 'dark' })
16
+ * destroy()
14
17
  */
15
- export function mount(app: FastboardApp, dom: HTMLElement, props: Omit<FastboardProps & DivProps, "ref">) {
18
+ export function mount(app: FastboardApp, dom: HTMLElement, props: MountProps) {
16
19
  ReactDOM.render(<Fastboard app={app} {...props} />, dom);
17
- return () => ReactDOM.unmountComponentAtNode(dom);
20
+ return {
21
+ update(props: MountProps) {
22
+ ReactDOM.render(<Fastboard app={app} {...props} />, dom);
23
+ },
24
+ destroy() {
25
+ ReactDOM.unmountComponentAtNode(dom);
26
+ },
27
+ };
18
28
  }
@@ -1,21 +0,0 @@
1
- import type { IconProps } from "../typings";
2
-
3
- import React from "react";
4
- import { themes } from "../theme";
5
-
6
- export function ChevronLeft({ theme = "light", active }: IconProps) {
7
- const config = themes[theme];
8
- const stroke = active ? config.activeColor : config.color;
9
-
10
- return (
11
- <svg viewBox="0 0 24 24">
12
- <path
13
- fill="none"
14
- stroke={stroke}
15
- strokeLinecap="round"
16
- strokeLinejoin="round"
17
- d="m14 16-2-2-2-2 2-2 2-2"
18
- />
19
- </svg>
20
- );
21
- }
@@ -1,21 +0,0 @@
1
- import type { IconProps } from "../typings";
2
-
3
- import React from "react";
4
- import { themes } from "../theme";
5
-
6
- export function ChevronRight({ theme = "light", active }: IconProps) {
7
- const config = themes[theme];
8
- const stroke = active ? config.activeColor : config.color;
9
-
10
- return (
11
- <svg viewBox="0 0 24 24">
12
- <path
13
- fill="none"
14
- stroke={stroke}
15
- strokeLinecap="round"
16
- strokeLinejoin="round"
17
- d="m10 16 2-2 2-2-2-2-2-2"
18
- />
19
- </svg>
20
- );
21
- }
@@ -1,18 +0,0 @@
1
- import type { IconProps } from "../typings";
2
-
3
- import React from "react";
4
- import { themes } from "../theme";
5
-
6
- export function FilePlus({ theme = "light", active }: IconProps) {
7
- const config = themes[theme];
8
- const stroke = active ? config.activeColor : config.color;
9
-
10
- return (
11
- <svg viewBox="0 0 24 24">
12
- <path
13
- fill={stroke}
14
- d="M12 7.5a.5.5 0 0 1 .09.992L12 8.5H8a1.5 1.5 0 0 0-1.493 1.356L6.5 10v6a1.5 1.5 0 0 0 1.356 1.493L8 17.5h6a1.5 1.5 0 0 0 1.493-1.356L15.5 16v-4a.5.5 0 0 1 .992-.09l.008.09v4a2.5 2.5 0 0 1-2.336 2.495L14 18.5H8a2.5 2.5 0 0 1-2.495-2.336L5.5 16v-6a2.5 2.5 0 0 1 2.336-2.495L8 7.5h4Zm4-2a.5.5 0 0 1 .492.41L16.5 6v1.5H18a.5.5 0 0 1 .09.992L18 8.5h-1.5V10a.5.5 0 0 1-.992.09L15.5 10V8.5H14a.5.5 0 0 1-.09-.992L14 7.5h1.5V6a.5.5 0 0 1 .5-.5Z"
15
- />
16
- </svg>
17
- );
18
- }