import { useState } from 'react'; import * as HugeIcons from 'hugeicons-react'; import iconNames from '../../utils/icon_names.json'; interface IconPickerProps { onSelect: (iconName: string, color?: string) => void; onClose: () => void; } export default function IconPicker({ onSelect, onClose }: IconPickerProps) { const [search, setSearch] = useState(''); const [selectedColor, setSelectedColor] = useState(undefined); const COLORS = [ '#2e6ff2', '#e11d48', '#d97706', '#16a34a', '#9333ea', '#db2777', '#0891b2', '#475569', '#111111' ]; const filteredIcons = iconNames.filter(name => name.toLowerCase().includes(search.toLowerCase()) ).slice(0, 100); // Limit results for performance return (
e.stopPropagation()} style={{ background: 'var(--bg-panel)', padding: '16px', borderRadius: '8px', boxShadow: '0 8px 32px rgba(0,0,0,0.15)', width: '400px', maxHeight: '500px', display: 'flex', flexDirection: 'column', border: '1px solid var(--border-color)' }}> setSearch(e.target.value)} style={{ width: '100%', padding: '10px', marginBottom: '12px', border: '1px solid var(--border-color)', borderRadius: '4px', outline: 'none', fontSize: '14px' }} />
{filteredIcons.map(name => { const Icon = (HugeIcons as any)[name]; if (!Icon) return null; return ( ); })}
{COLORS.map(c => (
setSelectedColor(c)} style={{ width: '20px', height: '20px', borderRadius: '50%', backgroundColor: c, cursor: 'pointer', border: selectedColor === c ? '2px solid var(--text-primary)' : '2px solid transparent', boxShadow: '0 2px 4px rgba(0,0,0,0.1)' }} /> ))}
setSelectedColor(undefined)} style={{ width: '20px', height: '20px', borderRadius: '50%', border: '1px dashed var(--text-secondary)', cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '10px' }} > x
{filteredIcons.length === 0 && (
No icons found
)}
); }