From 7f0ab7269a43eeb68374dadf63bce254ce8fb4da Mon Sep 17 00:00:00 2001 From: hqer927 <285569480@qq.com> Date: Fri, 29 Nov 2024 18:42:11 +0800 Subject: [PATCH] feat: toolbar add laserPen --- .../fastboard-core/src/impl/FastboardApp.ts | 10 +++--- .../src/components/Icons/LaserPen.svelte | 20 +++++++++++ .../components/Icons/LaserPenFilled.svelte | 20 +++++++++++ .../src/components/Icons/index.ts | 4 +++ .../Toolbar/components/Contents.scss | 9 +++++ .../Toolbar/components/Contents.svelte | 35 +++++++++++++++++-- .../Toolbar/definitions/Pencil.svelte | 5 ++- packages/fastboard/test/main.ts | 6 ++-- 8 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 packages/fastboard-ui/src/components/Icons/LaserPen.svelte create mode 100644 packages/fastboard-ui/src/components/Icons/LaserPenFilled.svelte diff --git a/packages/fastboard-core/src/impl/FastboardApp.ts b/packages/fastboard-core/src/impl/FastboardApp.ts index 1d0b5a4..3b6051c 100644 --- a/packages/fastboard-core/src/impl/FastboardApp.ts +++ b/packages/fastboard-core/src/impl/FastboardApp.ts @@ -1,7 +1,6 @@ import type { AddPageParams, PublicEvent, MountParams, NetlessApp } from "@netless/window-manager"; import type { AnimationMode, - ApplianceNames, Camera, CameraState, Color, @@ -21,6 +20,7 @@ import type { WhiteWebSdkConfiguration, RoomMember, FloatBarOptions, + ApplianceNames, } from "white-web-sdk"; import type { SyncedStore, Storage, Diff, DiffOne } from "@netless/synced-store"; @@ -39,7 +39,7 @@ import { import { ensure_official_plugins, transform_app_status } from "../internal"; import { register } from "../behaviors/lite"; import { ApplianceMultiPlugin } from "@netless/appliance-plugin"; -import type { AppliancePluginOptions, AppliancePluginInstance } from "@netless/appliance-plugin"; +import type { AppliancePluginOptions, AppliancePluginInstance, ApplianceNames as ExtendApplianceNames, MemberState as ExtendMemberState} from "@netless/appliance-plugin"; function noop() {} @@ -129,10 +129,12 @@ export type { WhiteWebSdk, WhiteWebSdkConfiguration, WindowManager, + ExtendApplianceNames, + ExtendMemberState }; /** pencil, eraser, rectangle... */ -export type Appliance = `${ApplianceNames}`; +export type Appliance = `${ExtendApplianceNames}`; /** triangle, star... */ export type Shape = `${ShapeType}`; @@ -377,7 +379,7 @@ export class FastboardApp = any> extends /** * Set current tool, like "pencil". */ - setAppliance(appliance: ApplianceNames | Appliance, shape?: ShapeType | Shape) { + setAppliance(appliance: ExtendApplianceNames | Appliance, shape?: ShapeType | Shape) { this._assertNotDestroyed(); this.manager.mainView.setMemberState({ currentApplianceName: appliance as ApplianceNames, diff --git a/packages/fastboard-ui/src/components/Icons/LaserPen.svelte b/packages/fastboard-ui/src/components/Icons/LaserPen.svelte new file mode 100644 index 0000000..783f2fb --- /dev/null +++ b/packages/fastboard-ui/src/components/Icons/LaserPen.svelte @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/packages/fastboard-ui/src/components/Icons/LaserPenFilled.svelte b/packages/fastboard-ui/src/components/Icons/LaserPenFilled.svelte new file mode 100644 index 0000000..6a8ea5b --- /dev/null +++ b/packages/fastboard-ui/src/components/Icons/LaserPenFilled.svelte @@ -0,0 +1,20 @@ + + + + + + + + diff --git a/packages/fastboard-ui/src/components/Icons/index.ts b/packages/fastboard-ui/src/components/Icons/index.ts index d25a118..b078bb6 100644 --- a/packages/fastboard-ui/src/components/Icons/index.ts +++ b/packages/fastboard-ui/src/components/Icons/index.ts @@ -45,6 +45,8 @@ import WhiteboardAdd from "./WhiteboardAdd.svelte"; import Play from "./Play.svelte"; import Pause from "./Pause.svelte"; import Loading from "./Loading.svelte"; +import LaserPen from "./LaserPen.svelte"; +import LaserPenFilled from "./LaserPenFilled.svelte"; const Icons = { Apps, @@ -94,6 +96,8 @@ const Icons = { Play, Pause, Loading, + LaserPen, + LaserPenFilled }; export default Icons; diff --git a/packages/fastboard-ui/src/components/Toolbar/components/Contents.scss b/packages/fastboard-ui/src/components/Toolbar/components/Contents.scss index f138059..cd8382d 100644 --- a/packages/fastboard-ui/src/components/Toolbar/components/Contents.scss +++ b/packages/fastboard-ui/src/components/Toolbar/components/Contents.scss @@ -60,6 +60,15 @@ $name: "fastboard-toolbar"; display: none; } +.#{$name}-panel-switch-pencil{ + display: flex; +} + +.#{$name}-panel-switch-btn{ + width: 24px; + height: 24px; +} + .#{$name}-panel { display: flex; flex-direction: column; diff --git a/packages/fastboard-ui/src/components/Toolbar/components/Contents.svelte b/packages/fastboard-ui/src/components/Toolbar/components/Contents.svelte index 0ff4483..b5d9a53 100644 --- a/packages/fastboard-ui/src/components/Toolbar/components/Contents.svelte +++ b/packages/fastboard-ui/src/components/Toolbar/components/Contents.svelte @@ -1,5 +1,5 @@ {#if scrollable} @@ -121,7 +127,15 @@ {:else if item === "selector"} {:else if item === "pencil"} - + {:else if item === "text"} {:else if item === "shapes"} @@ -156,6 +170,23 @@