|
1 | 1 | import React, { useState } from "react"; |
2 | 2 | import Link from "next/link"; |
| 3 | +import { usePathname } from "next/navigation"; |
3 | 4 | import { |
4 | 5 | Code2, |
5 | 6 | Bell, |
@@ -28,7 +29,6 @@ import { |
28 | 29 | SidebarMenuButton, |
29 | 30 | SidebarMenuItem, |
30 | 31 | SidebarProvider, |
31 | | - SidebarTrigger, |
32 | 32 | } from "@/components/ui/sidebar" |
33 | 33 | import { Button } from "@/components/ui/button" |
34 | 34 | import { Sheet, SheetContent, SheetTrigger } from "@/components/ui/sheet" |
@@ -56,6 +56,7 @@ interface SidebarProps { |
56 | 56 | export function Sidebar({ avatar, name, email, role, sidebarItems, children }: SidebarProps) { |
57 | 57 | const [mobileOpen, setMobileOpen] = useState(false); |
58 | 58 | const closeSidebar = () => setMobileOpen(false); |
| 59 | + const pathname = usePathname(); |
59 | 60 | return ( |
60 | 61 | <SidebarProvider> |
61 | 62 | <div className="w-full bg-zinc-900"> |
@@ -93,7 +94,7 @@ export function Sidebar({ avatar, name, email, role, sidebarItems, children }: S |
93 | 94 | <Link |
94 | 95 | key={item.title} |
95 | 96 | href={item.url} |
96 | | - className="flex items-center gap-3 px-4 py-2 rounded-lg transition-all hover:bg-purple-700/10 active:bg-purple-800/20 text-zinc-200 hover:text-white font-medium" |
| 97 | + className={`flex items-center gap-3 px-4 py-2 rounded-lg transition-all hover:bg-purple-700/10 active:bg-purple-800/20 text-zinc-200 hover:text-white font-medium ${pathname === item.url ? "bg-purple-800/30 text-white" : ""}`} |
97 | 98 | onClick={closeSidebar} |
98 | 99 | > |
99 | 100 | <span className="text-purple-400"> |
@@ -193,7 +194,7 @@ export function Sidebar({ avatar, name, email, role, sidebarItems, children }: S |
193 | 194 | <SidebarMenu> |
194 | 195 | {group.items.map((item) => ( |
195 | 196 | <SidebarMenuItem key={item.title}> |
196 | | - <SidebarMenuButton asChild className="group flex items-center gap-3 px-6 py-2 rounded-lg transition-all hover:bg-purple-700/10 active:bg-purple-800/20 focus:bg-purple-800/20 text-zinc-200 hover:text-white font-medium"> |
| 197 | + <SidebarMenuButton asChild className={`group flex items-center gap-3 px-6 py-2 rounded-lg transition-all hover:bg-purple-700/10 active:bg-purple-800/20 focus:bg-purple-800/20 text-zinc-200 hover:text-white font-medium ${pathname === item.url ? "bg-purple-800/30 text-white" : ""}`}> |
197 | 198 | <Link href={item.url} className="flex items-center w-full"> |
198 | 199 | <span className="mr-3 text-purple-400 group-hover:text-purple-300"> |
199 | 200 | {React.createElement(item.icon, { className: "size-5" })} |
@@ -270,7 +271,6 @@ export function Sidebar({ avatar, name, email, role, sidebarItems, children }: S |
270 | 271 | <SidebarInset> |
271 | 272 | <header className="flex h-16 shrink-0 items-center gap-2 transition-[width,height] ease-linear group-has-[[data-collapsible=icon]]/sidebar-wrapper:h-12 px-4 pl-14 md:pl-0 border-b border-zinc-800 bg-[#10172a]"> |
272 | 273 | <div className="flex items-center gap-2"> |
273 | | - <SidebarTrigger className="-ml-1 hidden md:block" /> |
274 | 274 | <div className="h-4 w-px bg-sidebar-border hidden md:block" /> |
275 | 275 | <div className="flex items-center gap-2"> |
276 | 276 | <span className="font-semibold text-white">Admin Dashboard</span> |
|
0 commit comments