"use client"; import React, { useState } from "react"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { motion, AnimatePresence } from "framer-motion"; import { LayoutDashboard, Image, Video, FileText, Music, ChevronRight, ChevronDown, Menu, X, } from "lucide-react"; interface SidebarItem { title: string; icon: React.ComponentType<{ className?: string }>; link?: string; children?: SidebarItem[]; } const sidebarItems: SidebarItem[] = [ { title: "Dashboard", icon: LayoutDashboard, link: "/admin/dashboard", }, { title: "Content Management", icon: FileText, children: [ { title: "Foto", icon: Image, link: "/admin/content/image", }, { title: "Audio Visual", icon: Video, link: "/admin/content/audio-visual", }, { title: "Teks", icon: FileText, link: "/admin/content/document", }, { title: "Audio", icon: Music, link: "/admin/content/audio", }, ], }, ]; interface ModernSidebarProps { isOpen: boolean; onToggle: () => void; } export const ModernSidebar: React.FC = ({ isOpen, onToggle, }) => { const pathname = usePathname(); const [expandedItems, setExpandedItems] = useState([]); const toggleExpanded = (title: string) => { setExpandedItems((prev) => prev.includes(title) ? prev.filter((item) => item !== title) : [...prev, title] ); }; const SidebarItemComponent: React.FC<{ item: SidebarItem; level?: number; }> = ({ item, level = 0 }) => { const isExpanded = expandedItems.includes(item.title); const hasChildren = item.children && item.children.length > 0; const isActive = pathname === item.link; if (hasChildren) { return (
{/* Parent Menu */} {/* Expanded Submenu (when sidebar is open) */} {isOpen && isExpanded && (
{item.children?.map((child) => ( ))}
)}
{/* Collapsed Submenu Icons (when sidebar is collapsed) */} {!isOpen && (
{item.children?.map((child) => (
))}
)}
); } return (
0 ? "ml-4" : ""}`} > {isOpen && ( {item.title} )}
); }; return ( <> {/* Mobile Overlay */} {isOpen && ( )} {/* Sidebar */} {/* Header */}
N
{isOpen && (

Netidhub

Admin Panel

)}
{/* Navigation */}
{/* Floating Toggle Button - Expand */} {!isOpen && ( )} {/* Floating Toggle Button - Collapse */} {isOpen && ( )} ); };