import { useState, type ComponentType } from 'react' import { FileText, Wrench, Flask, Target, ArrowsClockwise, Users, CalendarBlank, Tag, StackSimple, BookOpen, CookingPot, Heart, Star, House, Lightbulb, Briefcase, Gear, Cube, Leaf, MusicNote, Camera, Airplane, GameController, PaintBrush, ShoppingCart, GraduationCap, Trophy, ChatCircle, Notebook, MapPin, Code, Barbell, PawPrint, Pill, Knife, type IconProps, } from '@phosphor-icons/react' import { ACCENT_COLORS } from '../utils/typeColors' import { cn } from '@/lib/utils' /** Curated Phosphor icons (normal weight) for type customization */ // eslint-disable-next-line react-refresh/only-export-components -- constant co-located with component export const ICON_OPTIONS: { name: string; Icon: ComponentType }[] = [ { name: 'file-text', Icon: FileText }, { name: 'wrench', Icon: Wrench }, { name: 'flask', Icon: Flask }, { name: 'target', Icon: Target }, { name: 'arrows-clockwise', Icon: ArrowsClockwise }, { name: 'users', Icon: Users }, { name: 'calendar-blank', Icon: CalendarBlank }, { name: 'tag', Icon: Tag }, { name: 'stack-simple', Icon: StackSimple }, { name: 'book-open', Icon: BookOpen }, { name: 'cooking-pot', Icon: CookingPot }, { name: 'heart', Icon: Heart }, { name: 'star', Icon: Star }, { name: 'house', Icon: House }, { name: 'lightbulb', Icon: Lightbulb }, { name: 'briefcase', Icon: Briefcase }, { name: 'gear', Icon: Gear }, { name: 'cube', Icon: Cube }, { name: 'leaf', Icon: Leaf }, { name: 'music-note', Icon: MusicNote }, { name: 'camera', Icon: Camera }, { name: 'airplane', Icon: Airplane }, { name: 'game-controller', Icon: GameController }, { name: 'paint-brush', Icon: PaintBrush }, { name: 'shopping-cart', Icon: ShoppingCart }, { name: 'graduation-cap', Icon: GraduationCap }, { name: 'trophy', Icon: Trophy }, { name: 'chat-circle', Icon: ChatCircle }, { name: 'notebook', Icon: Notebook }, { name: 'map-pin', Icon: MapPin }, { name: 'code', Icon: Code }, { name: 'barbell', Icon: Barbell }, { name: 'paw-print', Icon: PawPrint }, { name: 'pill', Icon: Pill }, { name: 'knife', Icon: Knife }, ] const ICON_MAP: Record> = Object.fromEntries( ICON_OPTIONS.map((o) => [o.name, o.Icon]), ) /** Resolves a Phosphor icon name to its component, with fallback to FileText */ // eslint-disable-next-line react-refresh/only-export-components -- utility co-located with component export function resolveIcon(name: string | null): ComponentType { return (name && ICON_MAP[name]) || FileText } interface TypeCustomizePopoverProps { currentIcon: string | null currentColor: string | null onChangeIcon: (icon: string) => void onChangeColor: (color: string) => void onClose: () => void } export function TypeCustomizePopover({ currentIcon, currentColor, onChangeIcon, onChangeColor, onClose, }: TypeCustomizePopoverProps) { const [selectedColor, setSelectedColor] = useState(currentColor) const [selectedIcon, setSelectedIcon] = useState(currentIcon) const handleColorClick = (key: string) => { setSelectedColor(key) onChangeColor(key) } const handleIconClick = (name: string) => { setSelectedIcon(name) onChangeIcon(name) } return (
e.stopPropagation()} onContextMenu={(e) => e.stopPropagation()} > {/* Color section */}
COLOR
{ACCENT_COLORS.map((c) => (
{/* Icon section */}
ICON
{ICON_OPTIONS.map(({ name, Icon }) => ( ))}
{/* Done button */}
) }