({
activeCategories,
onToggle,
}: LayersPanelProps)
| 21 | ]; |
| 22 | |
| 23 | export default function LayersPanel({ |
| 24 | activeCategories, |
| 25 | onToggle, |
| 26 | }: LayersPanelProps) { |
| 27 | const [open, setOpen] = useState(false); |
| 28 | const panelRef = useRef<HTMLDivElement>(null); |
| 29 | |
| 30 | useEffect(() => { |
| 31 | if (!open) return; |
| 32 | const handler = (e: MouseEvent) => { |
| 33 | if (panelRef.current && !panelRef.current.contains(e.target as Node)) { |
| 34 | setOpen(false); |
| 35 | } |
| 36 | }; |
| 37 | document.addEventListener("mousedown", handler); |
| 38 | return () => document.removeEventListener("mousedown", handler); |
| 39 | }, [open]); |
| 40 | |
| 41 | return ( |
| 42 | <div ref={panelRef} className="absolute bottom-2.5 left-2.5 z-10"> |
| 43 | {open && ( |
| 44 | <div className="mb-1.5 bg-[#0a0a0a]/90 border border-[#2a2a2a] p-2.5 backdrop-blur-sm min-w-[140px] shadow-lg animate-fade-in font-mono"> |
| 45 | <div className="text-[13px] uppercase tracking-[0.15em] text-[#777] mb-1.5"> |
| 46 | layers |
| 47 | </div> |
| 48 | {CATEGORIES.map((cat) => { |
| 49 | const active = activeCategories.has(cat); |
| 50 | return ( |
| 51 | <label |
| 52 | key={cat} |
| 53 | className="flex items-center gap-2 py-0.5 px-1 cursor-pointer hover:bg-[#fff]/5 transition-colors text-[12px]" |
| 54 | onClick={() => onToggle(cat)} |
| 55 | > |
| 56 | <ShapeIcon |
| 57 | shape={CATEGORY_SHAPES[cat]} |
| 58 | color={active ? CATEGORY_COLORS[cat] : "#444"} |
| 59 | filled={active} |
| 60 | size={10} |
| 61 | /> |
| 62 | <span className={active ? "text-[#ccc]" : "text-[#777]"}> |
| 63 | {cat.toLowerCase()} |
| 64 | </span> |
| 65 | </label> |
| 66 | ); |
| 67 | })} |
| 68 | </div> |
| 69 | )} |
| 70 | |
| 71 | <button |
| 72 | onClick={() => setOpen((prev) => !prev)} |
| 73 | className={`flex items-center gap-1.5 px-2 py-1 text-[12px] font-mono transition-colors ${ |
| 74 | open |
| 75 | ? "bg-[#1e1e1e] text-[#ccc] border border-[#2a2a2a]" |
| 76 | : "bg-[#0a0a0a]/80 text-[#8a8a8a] border border-[#2a2a2a] hover:text-[#a0a0a0] hover:bg-[#1e1e1e]" |
| 77 | } backdrop-blur-sm`} |
| 78 | > |
| 79 | <svg |
| 80 | width="10" |
nothing calls this directly
no outgoing calls
no test coverage detected