import { useState } from "react"; import { X, Search, Folder, Grid, Filter, Plus, Tag } from "lucide-react"; import { useAppStore } from "../store"; const ALL_TAGS = [ "anatomy", "environment", "character", "lighting", "cyberpunk", "fantasy", "sci-fi", ]; const mockLibrary = Array.from({ length: 24 }).map((_, i) => ({ url: `https://picsum.photos/id/${100 + i}/400/400`, tags: [ALL_TAGS[i % ALL_TAGS.length], ALL_TAGS[(i + 2) % ALL_TAGS.length]], })); export const LibraryPanel = () => { const { isLibraryOpen, setIsLibraryOpen, setImages, pan, zoom } = useAppStore(); const [search, setSearch] = useState(""); const [activeTag, setActiveTag] = useState(null); const handleAdd = (src: string) => { const newImg = { id: Math.random().toString(36).substr(2, 9), url: src, x: (-pan.x + window.innerWidth / 4) / zoom, y: (-pan.y + window.innerHeight / 4) / zoom, width: 250, height: 250, aspectRatio: 1, }; setImages((prev) => [...prev, newImg]); }; const filteredLibrary = mockLibrary.filter((img) => { if (activeTag && !img.tags.includes(activeTag)) return false; if (search && !img.tags.some((t) => t.includes(search.toLowerCase()))) return false; return true; }); return (
Asset Library
setSearch(e.target.value)} placeholder="Search assets or tags..." className="w-full bg-[#1C1C1E] text-[#E0E0E0] pl-9 pr-3 py-2 text-[13px] rounded-lg border border-[#3A3A3E] focus:border-[#0A84FF] outline-none transition-all placeholder:text-[#808080]" />
{/* Tag Pills */}
{ALL_TAGS.map((tag) => ( ))}
Images ({filteredLibrary.length})
Upload File
{filteredLibrary.map((img, i) => (
handleAdd(img.url)} >
IMG_{100 + i}.jpg
{img.tags.map((t) => ( {t} ))}
))}
); };