diff --git a/src/pages/editor/components/LayersPanel.tsx b/src/pages/editor/components/LayersPanel.tsx index 7078a37..2806da7 100644 --- a/src/pages/editor/components/LayersPanel.tsx +++ b/src/pages/editor/components/LayersPanel.tsx @@ -1,4 +1,4 @@ -import { DocumentText, Layer, ArrowRight2 } from 'iconsax-react' +import { Layer, ArrowRight2, Book1 } from 'iconsax-react' import { clx } from '@/helpers/utils' import { useState } from 'react' import PagesPanel from './PagesPanel' @@ -25,7 +25,7 @@ const LayersPanel = ({ isOpen, setIsOpen }: LayersPanelProps) => { }} className="w-10 h-10 flex items-center justify-center rounded-lg hover:bg-gray-200 transition-colors" > - + diff --git a/src/pages/editor/components/sidebar/instructions/LinkInput.tsx b/src/pages/editor/components/sidebar/instructions/LinkInput.tsx index d9786fc..e136e4c 100644 --- a/src/pages/editor/components/sidebar/instructions/LinkInput.tsx +++ b/src/pages/editor/components/sidebar/instructions/LinkInput.tsx @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useState, useMemo } from "react"; import { useEditorStore, type ToolType } from "@/pages/editor/store/editorStore"; import Input from "@/components/Input"; import Button from "@/components/Button"; @@ -15,19 +15,32 @@ import { clx } from "@/helpers/utils"; type LinkType = "link" | "nextPage" | "prevPage" | "page" | "firstPage" | "lastPrev"; +const linkTypesConfig: Record< + LinkType, + { icon: React.ComponentType<{ size?: number; color?: string }>; label: string } +> = { + link: { icon: Link, label: "لینک" }, + nextPage: { icon: ArrowCircleRight, label: "صفحه بعدی" }, + prevPage: { icon: ArrowCircleLeft, label: "صفحه قبلی" }, + page: { icon: DocumentText, label: "صفحه" }, + firstPage: { icon: ArrowLeft, label: "اولین صفحه" }, + lastPrev: { icon: ArrowRight, label: "آخرین قبلی" }, +}; + const LinkInput = () => { const [selectedLinkType, setSelectedLinkType] = useState("link"); const [linkUrl, setLinkUrl] = useState(""); const [linkTitle, setLinkTitle] = useState(""); - const linkTypes: Array<{ type: LinkType; icon: React.ReactNode; label: string }> = [ - { type: "link", icon: , label: "لینک" }, - { type: "nextPage", icon: , label: "صفحه بعدی" }, - { type: "prevPage", icon: , label: "صفحه قبلی" }, - { type: "page", icon: , label: "صفحه" }, - { type: "firstPage", icon: , label: "اولین صفحه" }, - { type: "lastPrev", icon: , label: "آخرین قبلی" }, - ]; + const linkTypes = useMemo( + () => + (Object.entries(linkTypesConfig) as [LinkType, typeof linkTypesConfig[LinkType]][]) + .map(([type, config]) => ({ + type, + ...config, + })), + [] + ); const handleAddLink = () => { if (linkUrl.trim()) { @@ -58,6 +71,7 @@ const LinkInput = () => {
{linkTypes.map((item) => { const isSelected = selectedLinkType === item.type; + const Icon = item.icon; return ( );