From 849fb3d2af29187abb4f21e724ff557614b90280 Mon Sep 17 00:00:00 2001 From: Maze Winther Date: Tue, 1 Jul 2025 16:06:36 +0200 Subject: refactor: editor header --- .../src/components/editor/project-name-editor.tsx | 110 --------------------- 1 file changed, 110 deletions(-) delete mode 100644 apps/web/src/components/editor/project-name-editor.tsx (limited to 'apps/web/src/components/editor') diff --git a/apps/web/src/components/editor/project-name-editor.tsx b/apps/web/src/components/editor/project-name-editor.tsx deleted file mode 100644 index a4ff3878..00000000 --- a/apps/web/src/components/editor/project-name-editor.tsx +++ /dev/null @@ -1,110 +0,0 @@ -"use client"; - -import { useState, useRef, useEffect } from "react"; -import { Input } from "../ui/input"; -import { useProjectStore } from "@/stores/project-store"; -import { Edit2, Check, X } from "lucide-react"; -import { Button } from "../ui/button"; - -interface ProjectNameEditorProps { - className?: string; -} - -export function ProjectNameEditor({ className }: ProjectNameEditorProps) { - const { activeProject, renameProject } = useProjectStore(); - const [isEditing, setIsEditing] = useState(false); - const [editValue, setEditValue] = useState(""); - const inputRef = useRef(null); - - useEffect(() => { - if (activeProject) { - setEditValue(activeProject.name); - } - }, [activeProject]); - - useEffect(() => { - if (isEditing && inputRef.current) { - inputRef.current.focus(); - inputRef.current.select(); - } - }, [isEditing]); - - const handleStartEdit = () => { - if (activeProject) { - setEditValue(activeProject.name); - setIsEditing(true); - } - }; - - const handleSave = () => { - if (editValue.trim() && activeProject) { - renameProject(activeProject.id, editValue.trim()); - setIsEditing(false); - } - }; - - const handleCancel = () => { - if (activeProject) { - setEditValue(activeProject.name); - } - setIsEditing(false); - }; - - const handleKeyDown = (e: React.KeyboardEvent) => { - if (e.key === "Enter") { - handleSave(); - } else if (e.key === "Escape") { - handleCancel(); - } - }; - - if (!activeProject) { - return Loading...; - } - - if (isEditing) { - return ( -
- setEditValue(e.target.value)} - onKeyDown={handleKeyDown} - className="h-7 text-sm px-3 py-1 min-w-[200px]" - size={1} - /> - - -
- ); - } - - return ( -
- {activeProject.name} - -
- ); -} \ No newline at end of file -- cgit v1.3.1