import { FolderOpen, Grid3x3, HelpCircle, LayoutGrid, Settings, Workflow } from "lucide-react"; import type { ComponentType } from "react"; import { Link, useLocation } from "react-router-dom"; import { useTranslation } from "@/contexts/i18n-context"; import { cn } from "@/lib/utils"; import { ImageEditIcon } from "../common/image-edit-icon"; import { OtterLogo } from "../common/otter-logo"; interface SidebarItem { icon: ComponentType<{ className?: string }>; label: string; href?: string; } function useNavItems() { const { t } = useTranslation(); const topItems: SidebarItem[] = [ { icon: LayoutGrid, label: t.sidebar.tools, href: "/" }, { icon: Grid3x3, label: t.sidebar.grid, href: "/fullscreen" }, { icon: Workflow, label: t.sidebar.automate, href: "/automate" }, { icon: ImageEditIcon, label: t.sidebar.editor, href: "/editor" }, { icon: FolderOpen, label: t.sidebar.files, href: "/files" }, ]; const bottomItems: SidebarItem[] = [ { icon: HelpCircle, label: t.sidebar.help }, { icon: Settings, label: t.sidebar.settings }, ]; return { topItems, bottomItems }; } interface SidebarProps { onSettingsClick: () => void; onHelpClick: () => void; /** Called when a nav link is clicked (e.g., to close mobile sidebar). */ onNavClick?: () => void; /** When true, renders in expanded mode (for mobile overlay). */ expanded?: boolean; } export function Sidebar({ onSettingsClick, onHelpClick, onNavClick, expanded = false, }: SidebarProps) { const location = useLocation(); const { t } = useTranslation(); const { topItems, bottomItems } = useNavItems(); const renderItem = (item: SidebarItem, isActive: boolean) => { const content = expanded ? (
{item.label}
) : (
{item.label}
); if (item === bottomItems[1]) { return ( ); } if (item === bottomItems[0]) { return ( ); } return ( {content} ); }; if (expanded) { return ( ); } return ( ); }