Skip to content

Commit 9f2aed2

Browse files
committed
🚸 增加涂鸦的颜色标识
1 parent 2124ed0 commit 9f2aed2

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

app/src/pages/_toolbar.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import {
1414
RefreshCcw,
1515
Repeat,
1616
SaveAll,
17-
Slash,
1817
Square,
1918
Tag,
2019
Trash2,
20+
Waypoints,
2121
} from "lucide-react";
2222
import React, { useEffect, useState } from "react";
2323
import Box from "../components/Box";
@@ -48,10 +48,11 @@ interface ToolbarItemProps {
4848
icon: React.ReactNode; // 定义 icon 的类型
4949
handleFunction: () => void; // 定义 handleFunction 的类型
5050
description: string;
51-
isHighlight?: boolean;
51+
// isHighlight?: boolean;
52+
color?: Color; // 定义 color 的类型
5253
}
5354

54-
export function ToolbarItem({ icon, handleFunction, description, isHighlight = false }: ToolbarItemProps) {
55+
export function ToolbarItem({ icon, handleFunction, description, color = Color.Transparent }: ToolbarItemProps) {
5556
return (
5657
<div
5758
className="hover:bg-toolbar-icon-hover-bg text-toolbar-tooltip-text group relative flex h-8 w-8 cursor-pointer items-center justify-center rounded-md active:scale-90"
@@ -61,7 +62,13 @@ export function ToolbarItem({ icon, handleFunction, description, isHighlight = f
6162
<span className="bg-toolbar-tooltip-bg border-toolbar-tooltip-border text-toolbar-tooltip-text pointer-events-none absolute bottom-8 z-10 w-auto origin-right scale-90 whitespace-nowrap rounded border p-1 text-xs opacity-0 group-hover:scale-100 group-hover:opacity-100">
6263
{description}
6364
</span>
64-
{isHighlight && <div className="bg-panel-success-text absolute top-0 h-1 w-6 rounded-b-md" />}
65+
{/* {isHighlight && <div className="bg-panel-success-text absolute top-0 h-1 w-6 rounded-b-md" />} */}
66+
{color && color.a !== 0 && (
67+
<div
68+
className={"border-toolbar-border absolute bottom-1 left-1 h-2 w-1 rounded-full"}
69+
style={{ backgroundColor: color.toString(), outline: "1px solid", outlineColor: "bg-toolbar-border" }}
70+
></div>
71+
)}
6572
</div>
6673
);
6774
}
@@ -129,6 +136,8 @@ export default function Toolbar({ className = "" }: { className?: string }) {
129136
const [isDrawing, setIsDrawing] = useState(false);
130137
const [isSelecting, setIsSelecting] = useState(false);
131138
const [isConnecting, setIsConnecting] = useState(false);
139+
const [penStrokeColor, setPenStrokeColor] = useState(Color.Transparent);
140+
const [nodeFillColor, setNodeFillColor] = useState(Color.Transparent);
132141

133142
const update = () => {
134143
setSsHaveSelectedNode(StageManager.selectedNodeCount > 0);
@@ -171,6 +180,12 @@ export default function Toolbar({ className = "" }: { className?: string }) {
171180
selectConnectingMouse();
172181
}
173182

183+
Settings.watch("autoFillPenStrokeColor", (colorList) => {
184+
setPenStrokeColor(new Color(...colorList));
185+
});
186+
Settings.watch("autoFillNodeColor", (colorList) => {
187+
setNodeFillColor(new Color(...colorList));
188+
});
174189
return () => {
175190
clearInterval(intervalId);
176191
};
@@ -297,28 +312,27 @@ export default function Toolbar({ className = "" }: { className?: string }) {
297312

298313
<div className={toolBarGroupStyle}>
299314
<ToolbarItem
300-
description="左键:框选和移动模式"
301-
icon={<MousePointer />}
315+
description="左键:框选/移动/创建节点 模式"
316+
icon={<MousePointer className={cn(isSelecting ? "opacity-100" : "opacity-25")} />}
302317
handleFunction={() => {
303318
selectSelectingMouse();
304319
}}
305-
isHighlight={isSelecting}
320+
color={nodeFillColor}
306321
/>
307322
<ToolbarItem
308323
description="左键:涂鸦模式"
309-
icon={<Pencil className="rotate-90" />}
324+
icon={<Pencil className={cn(isDrawing ? "opacity-100" : "opacity-25", "rotate-90")} />}
310325
handleFunction={() => {
311326
selectDrawingMouse();
312327
}}
313-
isHighlight={isDrawing}
328+
color={penStrokeColor}
314329
/>
315330
<ToolbarItem
316-
description="左键:连接与斩断"
317-
icon={<Slash className="rotate-90" />}
331+
description="左键:连接/斩断 模式"
332+
icon={<Waypoints className={cn(isConnecting ? "opacity-100" : "opacity-25")} />}
318333
handleFunction={() => {
319334
selectConnectingMouse();
320335
}}
321-
isHighlight={isConnecting}
322336
/>
323337
</div>
324338

0 commit comments

Comments
 (0)