import { useState, useEffect, useRef } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, } from "@/components/ui/dialog"; import { Separator } from "@/components/ui/separator"; import { useBoardStore } from "@/stores/board-store"; import { MarkdownEditor } from "@/components/card-detail/MarkdownEditor"; import { ChecklistSection } from "@/components/card-detail/ChecklistSection"; import { LabelPicker } from "@/components/card-detail/LabelPicker"; import { DueDatePicker } from "@/components/card-detail/DueDatePicker"; import { AttachmentSection } from "@/components/card-detail/AttachmentSection"; interface CardDetailModalProps { cardId: string | null; onClose: () => void; } export function CardDetailModal({ cardId, onClose }: CardDetailModalProps) { const card = useBoardStore((s) => cardId ? s.board?.cards[cardId] ?? null : null ); const boardLabels = useBoardStore((s) => s.board?.labels ?? []); const updateCard = useBoardStore((s) => s.updateCard); const open = cardId != null && card != null; return ( !isOpen && onClose()}> {card && cardId && ( <> {/* Hidden accessible description */} Card detail editor
{/* Left panel: Title + Markdown (60%) */}
{/* Vertical separator */} {/* Right sidebar (40%) */}
)}
); } /* ---------- Inline editable title ---------- */ interface InlineTitleProps { cardId: string; title: string; updateCard: (cardId: string, updates: { title: string }) => void; } function InlineTitle({ cardId, title, updateCard }: InlineTitleProps) { const [editing, setEditing] = useState(false); const [draft, setDraft] = useState(title); const inputRef = useRef(null); // Sync when title changes externally useEffect(() => { setDraft(title); }, [title]); useEffect(() => { if (editing && inputRef.current) { inputRef.current.focus(); inputRef.current.select(); } }, [editing]); function handleSave() { const trimmed = draft.trim(); if (trimmed && trimmed !== title) { updateCard(cardId, { title: trimmed }); } else { setDraft(title); } setEditing(false); } function handleKeyDown(e: React.KeyboardEvent) { if (e.key === "Enter") { e.preventDefault(); handleSave(); } else if (e.key === "Escape") { setDraft(title); setEditing(false); } } if (editing) { return ( setDraft(e.target.value)} onBlur={handleSave} onKeyDown={handleKeyDown} className="font-heading text-xl text-pylon-text bg-transparent outline-none border-b border-pylon-accent pb-0.5" /> ); } return ( setEditing(true)} className="cursor-pointer font-heading text-xl text-pylon-text transition-colors hover:text-pylon-accent" > {title} ); } /* ---------- Cover color picker ---------- */ function CoverColorPicker({ cardId, coverColor }: { cardId: string; coverColor: string | null }) { const updateCard = useBoardStore((s) => s.updateCard); const presets = [ { hue: "160", label: "Teal" }, { hue: "240", label: "Blue" }, { hue: "300", label: "Purple" }, { hue: "350", label: "Pink" }, { hue: "25", label: "Red" }, { hue: "55", label: "Orange" }, { hue: "85", label: "Yellow" }, { hue: "130", label: "Lime" }, { hue: "200", label: "Cyan" }, { hue: "0", label: "Slate" }, ]; return (

Cover

{presets.map(({ hue, label }) => (
); }