diff --git a/src/pages/editor/components/sidebar/ToolInstructions.tsx b/src/pages/editor/components/sidebar/ToolInstructions.tsx index 2beefe6..3213984 100644 --- a/src/pages/editor/components/sidebar/ToolInstructions.tsx +++ b/src/pages/editor/components/sidebar/ToolInstructions.tsx @@ -7,8 +7,6 @@ import { SelectInstruction, RectangleInstruction, TextInstruction, - LineInstruction, - ArrowInstruction, StickerInstruction, GridInstruction, CustomShapeInstruction, @@ -38,9 +36,9 @@ const ToolInstructions = ({ tool }: ToolInstructionsProps) => { const simpleInstructions: Partial> = { select: , rectangle: , + line: , + arrow: , text: , - line: , - arrow: , sticker: , grid: , "custom-shape": , diff --git a/src/pages/editor/components/sidebar/ToolsBar.tsx b/src/pages/editor/components/sidebar/ToolsBar.tsx index c3f3aae..cf2d716 100644 --- a/src/pages/editor/components/sidebar/ToolsBar.tsx +++ b/src/pages/editor/components/sidebar/ToolsBar.tsx @@ -1,6 +1,5 @@ import { clx } from "@/helpers/utils"; import { - ArrowLeft, Gallery, Grid8, MouseSquare, @@ -9,7 +8,6 @@ import { Text, VideoSquare, Music, - Minus, Link2, Magicpen, } from "iconsax-react"; @@ -17,15 +15,13 @@ import type { ToolType } from "../../store/editorStore"; const tools: Array<{ icon: (color: string, variant?: "Bold" | "Outline" | "Broken" | "Bulk" | "Linear" | "TwoTone") => React.ReactNode; tool: ToolType; label: string }> = [ { icon: (color, variant) => , tool: "select", label: "انتخاب" }, - { icon: (color, variant) => , tool: "rectangle", label: "مستطیل" }, + { icon: (color, variant) => , tool: "rectangle", label: "اشکال" }, { icon: (color, variant) => , tool: "text", label: "متن" }, { icon: (color, variant) => , tool: "grid", label: "گرید" }, { icon: (color, variant) => , tool: "image", label: "گالری" }, { icon: (color, variant) => , tool: "link", label: "لینک" }, { icon: (color, variant) => , tool: "video", label: "ویدیو" }, { icon: (color, variant) => , tool: "audio", label: "صدا" }, - { icon: (color, variant) => , tool: "arrow", label: "پیکان" }, - { icon: (color, variant) => , tool: "line", label: "خط" }, { icon: (color, variant) => , tool: "sticker", label: "استیکر" }, { icon: (color, variant) => , tool: "custom-shape", label: "شکل سفارشی" }, ]; @@ -39,7 +35,10 @@ const ToolsBar = ({ tool, onToolClick }: ToolsBarProps) => { return (
{tools.map((item, index) => { - const isActive = tool === item.tool; + const isActive = + item.tool === "rectangle" + ? tool === "rectangle" || tool === "line" || tool === "arrow" + : tool === item.tool; const iconColor = "black"; const iconVariant: "Bold" | "Outline" | "Broken" | "Bulk" | "Linear" | "TwoTone" | undefined = isActive ? "Bold" : "Outline"; return ( diff --git a/src/pages/editor/components/sidebar/instructions/RectangleInstruction.tsx b/src/pages/editor/components/sidebar/instructions/RectangleInstruction.tsx index d0a27e4..d648e0f 100644 --- a/src/pages/editor/components/sidebar/instructions/RectangleInstruction.tsx +++ b/src/pages/editor/components/sidebar/instructions/RectangleInstruction.tsx @@ -1,10 +1,12 @@ import { type FC } from "react"; +import { ArrowLeft, Minus } from "iconsax-react"; import SquareIcon from "@/assets/icons/square.svg"; import CircleIcon from "@/assets/icons/circle.svg"; import TriangleIcon from "@/assets/icons/triangle.svg"; import StarIcon from "@/assets/icons/Star.svg"; import { Switch } from "@/components/ui/switch"; import { clx } from "@/helpers/utils"; +import { useEditorStore } from "@/pages/editor/store/editorStore"; import { useShapeStore, type ShapeType } from "@/pages/editor/store/shapeStore"; const shapeOptions: Array<{ id: ShapeType; label: string; icon: string; alt: string }> = [ @@ -14,21 +16,33 @@ const shapeOptions: Array<{ id: ShapeType; label: string; icon: string; alt: str { id: "abstract", label: "انتزاعی", icon: StarIcon, alt: "abstract" }, ]; +const drawOptions = [ + { tool: "line" as const, label: "خط", Icon: Minus }, + { tool: "arrow" as const, label: "پیکان", Icon: ArrowLeft }, +]; + const RectangleInstruction: FC = () => { + const tool = useEditorStore((state) => state.tool); + const setTool = useEditorStore((state) => state.setTool); const { activeShape, setActiveShape, useAsMask, setUseAsMask } = useShapeStore(); + const handleShapeClick = (shapeId: ShapeType) => { + setActiveShape(shapeId); + setTool("rectangle"); + }; + return (

اشکال

{shapeOptions.map((shape) => { - const isActive = activeShape === shape.id; + const isActive = tool === "rectangle" && activeShape === shape.id; return ( ); })} + {drawOptions.map(({ tool: drawTool, label, Icon }) => { + const isActive = tool === drawTool; + return ( + + ); + })}
-
-
استفاده برای ماسک
- -
+ {tool === "rectangle" && ( +
+
استفاده برای ماسک
+ +
+ )} + + {(tool === "line" || tool === "arrow") && ( +

+ {tool === "line" ? "برای رسم خط، روی کانوس کلیک کرده و بکشید" : "برای رسم پیکان، روی کانوس کلیک کرده و بکشید"} +

+ )}
); }; export default RectangleInstruction; - -