@netless/fastboard-react 0.2.13-canary.0 → 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.
Files changed (105) hide show
  1. package/README.md +49 -0
  2. package/dist/index.d.ts +11 -140
  3. package/dist/index.js +73 -2130
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +71 -2129
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +15 -23
  8. package/src/Fastboard.tsx +12 -0
  9. package/src/PageControl.tsx +11 -0
  10. package/src/RedoUndo.tsx +8 -0
  11. package/src/Toolbar.tsx +8 -0
  12. package/src/ZoomControl.tsx +11 -0
  13. package/src/hooks.tsx +53 -0
  14. package/src/index.tsx +19 -0
  15. package/src/style.scss +3 -26
  16. package/src/behaviors/style.ts +0 -4
  17. package/src/components/Fastboard.scss +0 -46
  18. package/src/components/Fastboard.tsx +0 -108
  19. package/src/components/PageControl/PageControl.scss +0 -84
  20. package/src/components/PageControl/PageControl.tsx +0 -101
  21. package/src/components/PageControl/hooks.ts +0 -24
  22. package/src/components/PageControl/index.ts +0 -2
  23. package/src/components/PlayerControl/PlayerControl.scss +0 -146
  24. package/src/components/PlayerControl/PlayerControl.tsx +0 -131
  25. package/src/components/PlayerControl/components/Button.tsx +0 -44
  26. package/src/components/PlayerControl/hooks.ts +0 -88
  27. package/src/components/PlayerControl/icons/Loading.tsx +0 -13
  28. package/src/components/PlayerControl/icons/Pause.tsx +0 -13
  29. package/src/components/PlayerControl/icons/Play.tsx +0 -13
  30. package/src/components/PlayerControl/icons/index.ts +0 -10
  31. package/src/components/PlayerControl/index.ts +0 -2
  32. package/src/components/RedoUndo/RedoUndo.scss +0 -56
  33. package/src/components/RedoUndo/RedoUndo.tsx +0 -76
  34. package/src/components/RedoUndo/hooks.ts +0 -18
  35. package/src/components/RedoUndo/index.ts +0 -2
  36. package/src/components/ReplayFastboard.tsx +0 -36
  37. package/src/components/Toolbar/Content.tsx +0 -89
  38. package/src/components/Toolbar/Toolbar.scss +0 -343
  39. package/src/components/Toolbar/Toolbar.tsx +0 -84
  40. package/src/components/Toolbar/components/ApplianceButtons.tsx +0 -108
  41. package/src/components/Toolbar/components/AppsButton.tsx +0 -134
  42. package/src/components/Toolbar/components/Button.tsx +0 -45
  43. package/src/components/Toolbar/components/ColorBox.tsx +0 -55
  44. package/src/components/Toolbar/components/CutLine.tsx +0 -8
  45. package/src/components/Toolbar/components/PencilButton.tsx +0 -66
  46. package/src/components/Toolbar/components/ShapesButton.tsx +0 -135
  47. package/src/components/Toolbar/components/Slider.tsx +0 -26
  48. package/src/components/Toolbar/components/TextButton.tsx +0 -62
  49. package/src/components/Toolbar/components/UpDownButtons.tsx +0 -49
  50. package/src/components/Toolbar/components/assets/cocos.png +0 -0
  51. package/src/components/Toolbar/components/assets/collapsed.png +0 -0
  52. package/src/components/Toolbar/components/assets/countdown.png +0 -0
  53. package/src/components/Toolbar/components/assets/expanded.png +0 -0
  54. package/src/components/Toolbar/components/assets/geogebra.png +0 -0
  55. package/src/components/Toolbar/components/assets/vscode.png +0 -0
  56. package/src/components/Toolbar/const.ts +0 -32
  57. package/src/components/Toolbar/hooks.ts +0 -89
  58. package/src/components/Toolbar/icons/Apps.tsx +0 -16
  59. package/src/components/Toolbar/icons/Arrow.tsx +0 -13
  60. package/src/components/Toolbar/icons/Circle.tsx +0 -13
  61. package/src/components/Toolbar/icons/Clean.tsx +0 -16
  62. package/src/components/Toolbar/icons/Clicker.tsx +0 -19
  63. package/src/components/Toolbar/icons/Collapse.tsx +0 -13
  64. package/src/components/Toolbar/icons/Diamond.tsx +0 -13
  65. package/src/components/Toolbar/icons/Down.tsx +0 -13
  66. package/src/components/Toolbar/icons/Eraser.tsx +0 -16
  67. package/src/components/Toolbar/icons/Expand.tsx +0 -13
  68. package/src/components/Toolbar/icons/Laser.tsx +0 -21
  69. package/src/components/Toolbar/icons/Line.tsx +0 -13
  70. package/src/components/Toolbar/icons/Loading.tsx +0 -13
  71. package/src/components/Toolbar/icons/Pencil.tsx +0 -16
  72. package/src/components/Toolbar/icons/Rectangle.tsx +0 -13
  73. package/src/components/Toolbar/icons/Selector.tsx +0 -13
  74. package/src/components/Toolbar/icons/SpeechBalloon.tsx +0 -17
  75. package/src/components/Toolbar/icons/Star.tsx +0 -17
  76. package/src/components/Toolbar/icons/Text.tsx +0 -13
  77. package/src/components/Toolbar/icons/Triangle.tsx +0 -13
  78. package/src/components/Toolbar/icons/Up.tsx +0 -13
  79. package/src/components/Toolbar/icons/index.ts +0 -42
  80. package/src/components/Toolbar/index.ts +0 -2
  81. package/src/components/ZoomControl/ZoomControl.scss +0 -84
  82. package/src/components/ZoomControl/ZoomControl.tsx +0 -96
  83. package/src/components/ZoomControl/hooks.ts +0 -50
  84. package/src/components/ZoomControl/index.ts +0 -2
  85. package/src/components/hooks.ts +0 -66
  86. package/src/components/tippy-util.ts +0 -8
  87. package/src/i18n/en.json +0 -31
  88. package/src/i18n/index.ts +0 -29
  89. package/src/i18n/zh-CN.json +0 -32
  90. package/src/icons/Left.tsx +0 -15
  91. package/src/icons/Minus.tsx +0 -15
  92. package/src/icons/Plus.tsx +0 -15
  93. package/src/icons/Redo.tsx +0 -19
  94. package/src/icons/Reset.tsx +0 -17
  95. package/src/icons/Right.tsx +0 -15
  96. package/src/icons/Undo.tsx +0 -19
  97. package/src/icons/WhiteboardAdd.tsx +0 -26
  98. package/src/icons/index.tsx +0 -11
  99. package/src/index.ts +0 -12
  100. package/src/internal/helpers.ts +0 -31
  101. package/src/internal/hooks.ts +0 -23
  102. package/src/internal/index.ts +0 -2
  103. package/src/theme.ts +0 -36
  104. package/src/typings.ts +0 -15
  105. package/src/vanilla/index.tsx +0 -28
@@ -1,55 +0,0 @@
1
- import type { Color } from "white-web-sdk";
2
-
3
- import clsx from "clsx";
4
- import React, { useContext } from "react";
5
-
6
- import { isEqualArray } from "../../../internal";
7
- import { ToolbarContext } from "../Toolbar";
8
-
9
- const colors: Record<string, Color> = {
10
- "#E02020": [224, 32, 32],
11
- "#F7B500": [247, 181, 0],
12
- "#6DD400": [109, 212, 0],
13
- "#32C5FF": [50, 197, 255],
14
- "#0091FF": [0, 145, 255],
15
- "#6236FF": [98, 54, 255],
16
- "#B620E0": [182, 32, 224],
17
- "#6D7278": [109, 114, 120],
18
- };
19
-
20
- const colorKeys = Object.keys(colors);
21
-
22
- export function ColorBox() {
23
- const { theme, memberState, setStrokeColor, writable } = useContext(ToolbarContext);
24
-
25
- const strokeColor = memberState?.strokeColor;
26
- const disabled = !writable;
27
-
28
- return (
29
- <div className={clsx("fastboard-toolbar-color-box", theme)}>
30
- {colorKeys.map((key: string) => (
31
- <div
32
- key={key}
33
- className={clsx("fastboard-toolbar-color-item", theme)}
34
- onClick={() => setStrokeColor(colors[key])}
35
- >
36
- <div
37
- className={clsx("fastboard-toolbar-color-border", theme, {
38
- active: strokeColor && isEqualArray(strokeColor, colors[key]),
39
- })}
40
- >
41
- <button
42
- className={clsx("fastboard-toolbar-color-btn")}
43
- style={{ background: key }}
44
- disabled={disabled}
45
- onClick={ev => {
46
- ev.stopPropagation();
47
- setStrokeColor(colors[key]);
48
- }}
49
- />
50
- </div>
51
- </div>
52
- ))}
53
- </div>
54
- );
55
- }
@@ -1,8 +0,0 @@
1
- import clsx from "clsx";
2
- import React, { useContext } from "react";
3
- import { ToolbarContext, name } from "../Toolbar";
4
-
5
- export function CutLine() {
6
- const { theme } = useContext(ToolbarContext);
7
- return <span className={clsx(`${name}-cut-line`, theme)} />;
8
- }
@@ -1,66 +0,0 @@
1
- import Tippy from "@tippyjs/react";
2
- import React, { useCallback, useContext } from "react";
3
- import { ApplianceNames } from "white-web-sdk";
4
-
5
- import { useTranslation } from "../../../i18n";
6
- import { Icon } from "../../../icons";
7
- import { defaultHotKeys } from "../../../internal";
8
- import { RightOffset } from "../../../theme";
9
- import { useFastboardApp } from "../../hooks";
10
- import { Icons } from "../icons";
11
- import { ToolbarContext } from "../Toolbar";
12
- import { renderToolTip } from "./ApplianceButtons";
13
- import { Button } from "./Button";
14
- import { ColorBox } from "./ColorBox";
15
- import { CutLine } from "./CutLine";
16
- import { Slider } from "./Slider";
17
-
18
- export function PencilButton() {
19
- const app = useFastboardApp();
20
- const { t } = useTranslation();
21
-
22
- const { theme, icons, writable, setAppliance, memberState } = useContext(ToolbarContext);
23
-
24
- const changeAppliance = useCallback(() => {
25
- setAppliance(ApplianceNames.pencil);
26
- }, [setAppliance]);
27
-
28
- const appliance = memberState?.currentApplianceName;
29
- const active = appliance === ApplianceNames.pencil;
30
- const disabled = !writable;
31
- const shortcut = (app?.hotKeys || defaultHotKeys).changeToPencil;
32
-
33
- return (
34
- <span className="fastboard-toolbar-btn-interactive">
35
- <Tippy
36
- className="fastboard-tip"
37
- content={renderPencilButtonContent()}
38
- theme={theme}
39
- placement="right-start"
40
- trigger="click"
41
- offset={RightOffset}
42
- arrow={false}
43
- interactive
44
- >
45
- <Button content={renderToolTip(t("pencil"), shortcut)} active={active} onClick={changeAppliance}>
46
- <Icon
47
- fallback={<Icons.Pencil theme={theme} active={active} />}
48
- src={disabled ? icons?.pencilIconDisable : icons?.pencilIcon}
49
- alt="[pencil]"
50
- />
51
- <span className="fastboard-toolbar-triangle" />
52
- </Button>
53
- </Tippy>
54
- </span>
55
- );
56
- }
57
-
58
- function renderPencilButtonContent() {
59
- return (
60
- <div className="fastboard-toolbar-panel pencil">
61
- <Slider />
62
- <CutLine />
63
- <ColorBox />
64
- </div>
65
- );
66
- }
@@ -1,135 +0,0 @@
1
- import type { ShapeType } from "white-web-sdk";
2
- import type { IconProps } from "../../../typings";
3
-
4
- import Tippy from "@tippyjs/react";
5
- import React, { useCallback, useContext } from "react";
6
- import { ApplianceNames } from "white-web-sdk";
7
-
8
- import { useTranslation } from "../../../i18n";
9
- import { RightOffset } from "../../../theme";
10
- import { ApplianceShapes, Shapes, ShapesMap } from "../const";
11
- import { ToolbarContext } from "../Toolbar";
12
- import { Button } from "./Button";
13
- import { ColorBox } from "./ColorBox";
14
- import { CutLine } from "./CutLine";
15
- import { Slider } from "./Slider";
16
-
17
- const ShapeTypes = new Set([...ApplianceShapes, ...Shapes]);
18
-
19
- export function ShapesButton() {
20
- const { t } = useTranslation();
21
- const { writable, theme, memberState, lastShape, setAppliance } = useContext(ToolbarContext);
22
-
23
- const appliance = memberState?.currentApplianceName;
24
- const shape = memberState?.shapeType;
25
-
26
- const key = (appliance === ApplianceNames.shape ? shape : appliance) as keyof typeof ShapesMap;
27
-
28
- const active = ShapeTypes.has(key);
29
-
30
- const CurrentIcon = ShapesMap[lastShape];
31
-
32
- const onClick = useCallback(() => {
33
- if ((ApplianceShapes as readonly ApplianceNames[]).includes(lastShape as ApplianceNames)) {
34
- setAppliance(lastShape as ApplianceNames);
35
- } else if (Shapes.includes(lastShape as ShapeType)) {
36
- setAppliance(ApplianceNames.shape, lastShape as ShapeType);
37
- }
38
- }, [lastShape, setAppliance]);
39
-
40
- return (
41
- <span className="fastboard-toolbar-btn-interactive">
42
- <Tippy
43
- className="fastboard-tip"
44
- content={renderShapesButtonContent()}
45
- theme={theme}
46
- placement="right-start"
47
- trigger="click"
48
- offset={RightOffset}
49
- arrow={false}
50
- interactive
51
- >
52
- <Button content={t("shape")} active={active} disabled={!writable} onClick={onClick}>
53
- <CurrentIcon theme={theme} active={active} />
54
- <span className="fastboard-toolbar-triangle" />
55
- </Button>
56
- </Tippy>
57
- </span>
58
- );
59
- }
60
-
61
- function renderShapesButtonContent() {
62
- return (
63
- <div className="fastboard-toolbar-panel shapes">
64
- <ShapesBox />
65
- <CutLine />
66
- <Slider />
67
- <CutLine />
68
- <ColorBox />
69
- </div>
70
- );
71
- }
72
-
73
- export function ShapesBox() {
74
- const { t } = useTranslation();
75
-
76
- return (
77
- <div className="fastboard-toolbar-shapes">
78
- {ApplianceShapes.map(Appliance => (
79
- <ApplianceShapeButton
80
- key={Appliance}
81
- content={t(Appliance)}
82
- Appliance={Appliance}
83
- Icon={ShapesMap[Appliance]}
84
- />
85
- ))}
86
- {Shapes.map(shape => (
87
- <ShapeShapeButton key={shape} content={t(shape)} shape={shape} Icon={ShapesMap[shape]} />
88
- ))}
89
- </div>
90
- );
91
- }
92
-
93
- interface ApplianceShapeButtonProps {
94
- content?: string;
95
- Appliance: ApplianceNames;
96
- Icon: React.ComponentType<IconProps>;
97
- }
98
-
99
- function ApplianceShapeButton({ content, Appliance, Icon }: ApplianceShapeButtonProps) {
100
- const { theme, writable, setAppliance, memberState } = useContext(ToolbarContext);
101
-
102
- const current = memberState?.currentApplianceName;
103
- const disabled = !writable;
104
-
105
- return (
106
- <Button content={content} disabled={disabled} placement="top" onClick={() => setAppliance(Appliance)}>
107
- <Icon theme={theme} active={current === Appliance} />
108
- </Button>
109
- );
110
- }
111
-
112
- interface ShapeShapeButtonProps {
113
- content?: string;
114
- shape: ShapeType;
115
- Icon: React.ComponentType<IconProps>;
116
- }
117
-
118
- function ShapeShapeButton({ content, shape, Icon }: ShapeShapeButtonProps) {
119
- const { theme, writable, setAppliance, memberState } = useContext(ToolbarContext);
120
-
121
- const appliance = memberState?.currentApplianceName;
122
- const current = appliance === ApplianceNames.shape && memberState?.shapeType;
123
- const disabled = !writable;
124
-
125
- return (
126
- <Button
127
- content={content}
128
- disabled={disabled}
129
- placement="top"
130
- onClick={() => setAppliance(ApplianceNames.shape, shape)}
131
- >
132
- <Icon theme={theme} active={current === shape} />
133
- </Button>
134
- );
135
- }
@@ -1,26 +0,0 @@
1
- import clsx from "clsx";
2
- import RcSlider from "rc-slider";
3
- import React, { useContext } from "react";
4
-
5
- import { themes } from "../../../theme";
6
- import { ToolbarContext } from "../Toolbar";
7
-
8
- export function Slider() {
9
- const { theme, writable, memberState, setStrokeWidth } = useContext(ToolbarContext);
10
- const { activeColor } = themes[theme];
11
-
12
- const strokeWidth = memberState?.strokeWidth || 0;
13
-
14
- return (
15
- <RcSlider
16
- disabled={!writable}
17
- className={clsx("fastboard-toolbar-slider", theme)}
18
- trackStyle={{ background: activeColor }}
19
- handleStyle={{ border: `1px solid ${activeColor}` }}
20
- value={strokeWidth}
21
- onChange={setStrokeWidth}
22
- min={1}
23
- max={32}
24
- />
25
- );
26
- }
@@ -1,62 +0,0 @@
1
- import Tippy from "@tippyjs/react";
2
- import React, { useCallback, useContext } from "react";
3
- import { ApplianceNames } from "white-web-sdk";
4
-
5
- import { useTranslation } from "../../../i18n";
6
- import { Icon } from "../../../icons";
7
- import { defaultHotKeys } from "../../../internal";
8
- import { RightOffset } from "../../../theme";
9
- import { useFastboardApp } from "../../hooks";
10
- import { Icons } from "../icons";
11
- import { ToolbarContext } from "../Toolbar";
12
- import { renderToolTip } from "./ApplianceButtons";
13
- import { Button } from "./Button";
14
- import { ColorBox } from "./ColorBox";
15
-
16
- export function TextButton() {
17
- const app = useFastboardApp();
18
- const { t } = useTranslation();
19
-
20
- const { theme, icons, writable, setAppliance, memberState } = useContext(ToolbarContext);
21
-
22
- const changeAppliance = useCallback(() => {
23
- setAppliance(ApplianceNames.text);
24
- }, [setAppliance]);
25
-
26
- const appliance = memberState?.currentApplianceName;
27
- const active = appliance === ApplianceNames.text;
28
- const disabled = !writable;
29
- const shortcut = (app?.hotKeys || defaultHotKeys).changeToText;
30
-
31
- return (
32
- <span className="fastboard-toolbar-btn-interactive">
33
- <Tippy
34
- className="fastboard-tip"
35
- content={renderTextButtonContent()}
36
- theme={theme}
37
- placement="right-start"
38
- trigger="click"
39
- offset={RightOffset}
40
- arrow={false}
41
- interactive
42
- >
43
- <Button content={renderToolTip(t("text"), shortcut)} active={active} onClick={changeAppliance}>
44
- <Icon
45
- fallback={<Icons.Text theme={theme} active={active} />}
46
- src={disabled ? icons?.textIconDisable : icons?.textIcon}
47
- alt="[text]"
48
- />
49
- <span className="fastboard-toolbar-triangle" />
50
- </Button>
51
- </Tippy>
52
- </span>
53
- );
54
- }
55
-
56
- function renderTextButtonContent() {
57
- return (
58
- <div className="fastboard-toolbar-panel text">
59
- <ColorBox />
60
- </div>
61
- );
62
- }
@@ -1,49 +0,0 @@
1
- import React, { useCallback, useContext } from "react";
2
-
3
- import { Icon } from "../../../icons";
4
- import { Icons } from "../icons";
5
- import { Button } from "./Button";
6
- import { CutLine } from "./CutLine";
7
- import { ToolbarContext } from "../Toolbar";
8
- import { ItemHeight } from "../const";
9
-
10
- export interface UpButtonProps {
11
- disabled: boolean;
12
- scrollTo: (height: number) => void;
13
- }
14
-
15
- export function UpButton({ disabled, scrollTo }: UpButtonProps) {
16
- const { theme, icons } = useContext(ToolbarContext);
17
- const scrollUp = useCallback(() => scrollTo(-ItemHeight), [scrollTo]);
18
-
19
- return (
20
- <>
21
- <Button content="Up" disabled={disabled} onClick={scrollUp}>
22
- <Icon
23
- fallback={<Icons.Up theme={theme} />}
24
- src={disabled ? icons?.upIconDisable : icons?.upIcon}
25
- alt="[up]"
26
- />
27
- </Button>
28
- <CutLine />
29
- </>
30
- );
31
- }
32
-
33
- export function DownButton({ disabled, scrollTo }: UpButtonProps) {
34
- const { theme, icons } = useContext(ToolbarContext);
35
- const scrollDown = useCallback(() => scrollTo(ItemHeight), [scrollTo]);
36
-
37
- return (
38
- <>
39
- <CutLine />
40
- <Button content="Down" disabled={disabled} onClick={scrollDown}>
41
- <Icon
42
- fallback={<Icons.Down theme={theme} />}
43
- src={disabled ? icons?.downIconDisable : icons?.downIcon}
44
- alt="[down]"
45
- />
46
- </Button>
47
- </>
48
- );
49
- }
@@ -1,32 +0,0 @@
1
- import { ApplianceNames, ShapeType } from "white-web-sdk";
2
- import { Icons } from "./icons";
3
-
4
- export const ShapesMap = {
5
- [ApplianceNames.rectangle]: Icons.Rectangle,
6
- [ApplianceNames.ellipse]: Icons.Circle,
7
- [ApplianceNames.straight]: Icons.Line,
8
- [ApplianceNames.arrow]: Icons.Arrow,
9
- [ShapeType.Pentagram]: Icons.Star,
10
- [ShapeType.Rhombus]: Icons.Diamond,
11
- [ShapeType.Triangle]: Icons.Triangle,
12
- [ShapeType.SpeechBalloon]: Icons.SpeechBalloon,
13
- } as const;
14
-
15
- export const ApplianceShapes = [
16
- ApplianceNames.rectangle,
17
- ApplianceNames.ellipse,
18
- ApplianceNames.straight,
19
- ApplianceNames.arrow,
20
- ] as const;
21
-
22
- export const Shapes = [
23
- ShapeType.Pentagram,
24
- ShapeType.Rhombus,
25
- ShapeType.Triangle,
26
- ShapeType.SpeechBalloon,
27
- ] as const;
28
-
29
- export const ItemHeight = 32 + 4;
30
- export const ItemsCount = 8;
31
- export const MaxHeight = ItemHeight * ItemsCount - 4;
32
- export const MinHeight = ItemHeight * 2 - 4;
@@ -1,89 +0,0 @@
1
- import type { ApplianceNames, Color, MemberState, ShapeType } from "white-web-sdk";
2
- import type { AppsStatus } from "@netless/fastboard-core";
3
-
4
- import { useCallback, useState } from "react";
5
-
6
- import { noop } from "../../internal";
7
- import { useFastboardApp, useFastboardValue, useWritable } from "../hooks";
8
- import { ShapesMap } from "./const";
9
-
10
- export type UnifiedShape = keyof typeof ShapesMap;
11
-
12
- export interface ToolbarHook {
13
- readonly writable: boolean;
14
- readonly memberState: MemberState | undefined;
15
- readonly lastShape: UnifiedShape;
16
- readonly appsStatus: AppsStatus;
17
- cleanCurrentScene(): void;
18
- setAppliance(appliance: ApplianceNames, shape?: ShapeType): void;
19
- setStrokeWidth(width: number): void;
20
- setStrokeColor(color: Color): void;
21
- }
22
-
23
- export function useRoomState() {
24
- return useFastboardValue(useFastboardApp().memberState);
25
- }
26
-
27
- export function useAppsStatus() {
28
- return useFastboardValue(useFastboardApp().appsStatus);
29
- }
30
-
31
- export function useToolbar(): ToolbarHook {
32
- const app = useFastboardApp();
33
- const writable = useWritable();
34
- const memberState = useRoomState();
35
- const appsStatus = useAppsStatus();
36
- const [lastShape, setLastShape] = useState<UnifiedShape>("rectangle" as ApplianceNames.rectangle);
37
-
38
- const cleanCurrentScene = useCallback(() => {
39
- app.cleanCurrentScene();
40
- }, [app]);
41
-
42
- const setAppliance = useCallback(
43
- (appliance: ApplianceNames, shape?: ShapeType) => {
44
- app.setAppliance(appliance, shape);
45
- if (shape) {
46
- setLastShape(shape);
47
- } else if (appliance in ShapesMap) {
48
- setLastShape(appliance as UnifiedShape);
49
- }
50
- },
51
- [app]
52
- );
53
-
54
- const setStrokeWidth = useCallback(
55
- (strokeWidth: number) => {
56
- app.setStrokeWidth(strokeWidth);
57
- },
58
- [app]
59
- );
60
-
61
- const setStrokeColor = useCallback(
62
- (strokeColor: Color) => {
63
- app.setStrokeColor(strokeColor);
64
- },
65
- [app]
66
- );
67
-
68
- return {
69
- writable,
70
- memberState,
71
- lastShape,
72
- appsStatus,
73
- cleanCurrentScene,
74
- setAppliance,
75
- setStrokeWidth,
76
- setStrokeColor,
77
- };
78
- }
79
-
80
- export const EmptyToolbarHook: ToolbarHook = {
81
- writable: false,
82
- memberState: undefined,
83
- lastShape: "rectangle" as ApplianceNames.rectangle,
84
- appsStatus: {},
85
- cleanCurrentScene: noop,
86
- setAppliance: noop,
87
- setStrokeWidth: noop,
88
- setStrokeColor: noop,
89
- };
@@ -1,16 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Apps = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <g fill={stroke}>
11
- <path d="M17.667 4.5h-3.334c-1.012 0-1.833.82-1.833 1.833V11.5h5.167c1.012 0 1.833-.82 1.833-1.833V6.333c0-1.012-.82-1.833-1.833-1.833Zm-3.334 1h3.334c.46 0 .833.373.833.833v3.334l-.006.104a.833.833 0 0 1-.827.729H13.5V6.333c0-.46.373-.833.833-.833Z" />
12
- <path d="M6.333 19.5A1.833 1.833 0 0 1 4.5 17.667v-3.334c0-.525.221-1 .576-1.334a1.822 1.822 0 0 1-.576-1.332V8.333c0-1.012.82-1.833 1.833-1.833H10A1.5 1.5 0 0 1 11.5 8v4.5h4.167c.962 0 1.75.74 1.827 1.683l.006.15v3.334c0 1.012-.82 1.833-1.833 1.833Zm4.167-6H6.333a.833.833 0 0 0-.827.729l-.006.104v3.334c0 .46.373.833.833.833H10.5v-5Zm5.167 0H11.5v5h4.167c.46 0 .833-.373.833-.833v-3.334a.833.833 0 0 0-.833-.833ZM10 7.5H6.333a.833.833 0 0 0-.833.833v3.334c0 .46.373.833.833.833H10.5V8a.5.5 0 0 0-.41-.492L10 7.5Z" />
13
- </g>
14
- </svg>
15
- );
16
- };
@@ -1,13 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Arrow = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <path fill={stroke} d="M19 5v6l-2.647-2.646L5.99 18.718l-.708-.708L15.645 7.646 13 5h6Z" />
11
- </svg>
12
- );
13
- };
@@ -1,13 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Circle = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <rect width="15" height="15" x="4.5" y="4.5" fill="none" stroke={stroke} rx="7.5" />
11
- </svg>
12
- );
13
- };
@@ -1,16 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Clean = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <path
11
- fill={stroke}
12
- d="M9.754 11.99c0 1.856-.711 3.62-1.96 4.951l-.151.155h1.403l.855-.853h.707l.853.853h2.635l.094-.064a6.237 6.237 0 0 0 2.559-4.781l.005-.26h1a7.237 7.237 0 0 1-2.994 5.862l-.229.16-.277.083h-3l-.353-.146-.647-.647-.646.647-.354.146h-3l-.286-.91.214-.148a6.237 6.237 0 0 0 2.567-4.787l.005-.26h1Zm4.772-6.502v2l.35.039a2.98 2.98 0 0 1 2.644 2.78l.006.181h-8a2.98 2.98 0 0 1 2.65-2.961l.35-.039v-2h2Z"
13
- />
14
- </svg>
15
- );
16
- };
@@ -1,19 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Clicker = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <g fill="none">
11
- <path d="M0 0h24v24H0z" />
12
- <path
13
- fill={stroke}
14
- d="m7 5.072 10.33 7.892-4.879.549 3.232 5.598-.866.5-3.233-5.597-2.914 3.95L7 5.072Z"
15
- />
16
- </g>
17
- </svg>
18
- );
19
- };
@@ -1,13 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Collapse = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <path fill="none" stroke={stroke} d="m8 10-2 2 2 2m10-8H6m12 12H6m12-4h-8m8-4h-8" />
11
- </svg>
12
- );
13
- };
@@ -1,13 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Diamond = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <path fill="none" stroke={stroke} d="M4.222 12 12 4.222 19.778 12 12 19.778z" />
11
- </svg>
12
- );
13
- };
@@ -1,13 +0,0 @@
1
- import type { IconProps } from "../../../typings";
2
-
3
- import React from "react";
4
- import { getStroke } from "../../../theme";
5
-
6
- export const Down = (props: IconProps) => {
7
- const stroke = getStroke(props);
8
- return (
9
- <svg viewBox="0 0 24 24">
10
- <path fill="none" stroke={stroke} d="m16 13-2 2-2 2-2-2-2-2m8-6-2 2-2 2-2-2-2-2" />
11
- </svg>
12
- );
13
- };