1+ 'use client' ;
2+
3+ import Link from 'next/link' ;
4+ import { usePathname } from 'next/navigation' ;
5+
6+ const items = [
7+ { href : '/dashboard' , label : 'Dashboard' } ,
8+ { href : '/dashboard/groups' , label : 'Groups' } ,
9+ { href : '/dashboard/activity' , label : 'Activity' } ,
10+ { href : '/dashboard/profile' , label : 'Profile' } ,
11+ { href : '/dashboard/settings' , label : 'Settings' } ,
12+ ] as const ;
13+
14+ function isActive ( pathname : string , href : string ) : boolean {
15+ if ( href === '/dashboard' ) {
16+ return pathname === href ;
17+ }
18+ return pathname === href || pathname . startsWith ( `${ href } /` ) ;
19+ }
20+
21+ export function Sidebar ( ) {
22+ const pathname = usePathname ( ) ;
23+
24+ return (
25+ < aside className = "md:sticky md:top-6" >
26+ < div className = "rounded-2xl border border-border bg-card p-4 shadow-glass backdrop-blur-glass" >
27+ < div className = "flex items-center justify-between" >
28+ < Link href = "/dashboard" className = "text-sm font-semibold tracking-wide text-text-primary" >
29+ FairShare
30+ </ Link >
31+ < span className = "text-xs text-text-secondary" > Web</ span >
32+ </ div >
33+
34+ < nav className = "mt-4 flex gap-1 overflow-x-auto md:flex-col md:gap-1.5 md:overflow-visible" >
35+ { items . map ( ( item ) => {
36+ const active = isActive ( pathname , item . href ) ;
37+ return (
38+ < Link
39+ key = { item . href }
40+ href = { item . href }
41+ className = { [
42+ 'whitespace-nowrap rounded-xl px-3 py-2 text-sm transition' ,
43+ active
44+ ? 'bg-white/10 text-text-primary'
45+ : 'text-text-secondary hover:bg-white/5 hover:text-text-primary' ,
46+ ] . join ( ' ' ) }
47+ >
48+ { item . label }
49+ </ Link >
50+ ) ;
51+ } ) }
52+ </ nav >
53+ </ div >
54+ </ aside >
55+ ) ;
56+ }
0 commit comments