import { useState } from "react"; import { Plus, Check } from "lucide-react"; import { OverlayScrollbarsComponent } from "overlayscrollbars-react"; import { Button } from "@/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { useBoardStore } from "@/stores/board-store"; import type { Label } from "@/types/board"; interface LabelPickerProps { cardId: string; cardLabelIds: string[]; boardLabels: Label[]; } const COLOR_SWATCHES = [ "#ef4444", // red "#f97316", // orange "#eab308", // yellow "#22c55e", // green "#06b6d4", // cyan "#3b82f6", // blue "#8b5cf6", // violet "#ec4899", // pink ]; export function LabelPicker({ cardId, cardLabelIds, boardLabels, }: LabelPickerProps) { const toggleCardLabel = useBoardStore((s) => s.toggleCardLabel); const addLabel = useBoardStore((s) => s.addLabel); const [newLabelName, setNewLabelName] = useState(""); const [newLabelColor, setNewLabelColor] = useState(COLOR_SWATCHES[0]); const [showCreate, setShowCreate] = useState(false); const currentLabels = boardLabels.filter((l) => cardLabelIds.includes(l.id)); function handleCreateLabel() { const trimmed = newLabelName.trim(); if (trimmed) { addLabel(trimmed, newLabelColor); setNewLabelName(""); setShowCreate(false); } } function handleCreateKeyDown(e: React.KeyboardEvent) { if (e.key === "Enter") { e.preventDefault(); handleCreateLabel(); } } return (
Toggle labels
{/* Existing labels */} {boardLabels.length > 0 && (No labels
)}