import { AnimatePresence, motion } from "framer-motion"; import { Package, Plus, Search } from "lucide-react"; import { useTranslation } from "react-i18next"; import { useUIStore } from "../stores/uiStore"; interface FabMenuProps { isSetupsPage: boolean; } const spring = { type: "spring", stiffness: 400, damping: 25 } as const; interface MenuItem { label: string; icon: React.ReactNode; onClick: () => void; } export function FabMenu({ isSetupsPage }: FabMenuProps) { const { t } = useTranslation(); const fabMenuOpen = useUIStore((s) => s.fabMenuOpen); const openFabMenu = useUIStore((s) => s.openFabMenu); const closeFabMenu = useUIStore((s) => s.closeFabMenu); const openCatalogSearch = useUIStore((s) => s.openCatalogSearch); const catalogSearchOpen = useUIStore((s) => s.catalogSearchOpen); // Hide FAB when catalog search overlay is open if (catalogSearchOpen) return null; const menuItems: MenuItem[] = [ { label: t("fab.addToCollection"), icon: , onClick: () => openCatalogSearch("collection"), }, { label: t("fab.startNewThread"), icon: , onClick: () => openCatalogSearch("thread"), }, ]; if (isSetupsPage) { menuItems.push({ label: t("fab.newSetup"), icon: , onClick: () => { closeFabMenu(); // Stub: setup creation is handled by the setups page itself }, }); } function handleFabClick() { if (fabMenuOpen) { closeFabMenu(); } else { openFabMenu(); } } return ( <> {/* Backdrop */} {fabMenuOpen && ( )} {/* Menu items */} {fabMenuOpen && (
{menuItems.map((item, index) => ( {item.icon} {item.label} ))}
)}
{/* FAB button */} ); }