"use client" import { Button } from "@/components/ui/button" import { ScrollArea } from "@/components/ui/scroll-area" import { cn } from "@/lib/utils" import { motion } from "framer-motion" import { ChevronLeft, ChevronRight } from "lucide-react" import Link from "next/link" import { usePathname } from "next/navigation" import { useState } from "react" import { DASHBOARDS } from "../constant/index" interface SidebarProps { className?: string } export function Sidebar({ className }: SidebarProps) { const [isOpen, setIsOpen] = useState(false) const pathname = usePathname() const toggleSidebar = () => { setIsOpen(!isOpen) } const sidebarVariants = { open: { width: 280, opacity: 1, display: "block", transition: { duration: 0.4, ease: [0.25, 0.46, 0.45, 0.94], }, }, closed: { width: 0, opacity: 0, display: "none", transition: { duration: 0.4, ease: [0.25, 0.46, 0.45, 0.94], }, }, } const contentVariants = { open: { opacity: 1, x: 0, transition: { duration: 0.4, delay: 0.1, ease: [0.25, 0.46, 0.45, 0.94], }, }, closed: { opacity: 0, x: -20, transition: { duration: 0.3, }, }, } return ( <> A Admin Panel Ecommerce Dashboard Main Menu e.stopPropagation()}> {DASHBOARDS.map((item) => { const isActive = pathname === item.url || pathname.startsWith(item.url + "/") return ( {isActive && ( )} {item.icon} {item.name} {item.badge && ( {item.badge} )} ) })} JD John Doe john@example.com {isOpen ? : } {isOpen && ( )} > ) }
Ecommerce Dashboard
Main Menu
John Doe
john@example.com