@@ -26,15 +26,43 @@ interface NavLinksProps {
2626 className ?: string ;
2727 onNavigate ?: ( ) => void ;
2828 showAdminLink ?: boolean ;
29+ includeHomeLink ?: boolean ; // NEW
2930}
3031
31- export function NavLinks ( { className, onNavigate, showAdminLink = false } : NavLinksProps ) {
32- const pathname = usePathname ( ) ;
32+ export function NavLinks ( {
33+ className,
34+ onNavigate,
35+ showAdminLink = false ,
36+ includeHomeLink = false ,
37+ } : NavLinksProps ) {
38+ const pathname = usePathname ( ) ;
3339 const searchParams = useSearchParams ( ) ;
3440 const currentCategory = searchParams . get ( 'category' ) ;
3541
42+ const baseLink =
43+ 'rounded-md px-3 py-2 text-sm font-medium transition-colors ' +
44+ 'hover:bg-muted/50 hover:text-foreground ' +
45+ 'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ' +
46+ 'focus-visible:ring-offset-2 focus-visible:ring-offset-background' ;
47+
48+ const isHomeActive = pathname === '/' ;
49+
3650 return (
37- < nav className = { cn ( 'items-center gap-1' , className ) } >
51+ < nav className = { cn ( 'flex items-center gap-1' , className ) } aria-label = "Shop categories" >
52+ { includeHomeLink ? (
53+ < Link
54+ href = "/"
55+ onClick = { onNavigate }
56+ aria-current = { isHomeActive ? 'page' : undefined }
57+ className = { cn (
58+ baseLink ,
59+ isHomeActive ? 'bg-muted text-foreground' : 'text-muted-foreground'
60+ ) }
61+ >
62+ Home
63+ </ Link >
64+ ) : null }
65+
3866 { NAV_LINKS . map ( link => {
3967 const [ linkPath , linkQuery ] = link . href . split ( '?' ) ;
4068 const linkParams = new URLSearchParams ( linkQuery ?? '' ) ;
@@ -49,9 +77,10 @@ export function NavLinks({ className, onNavigate, showAdminLink = false }: NavLi
4977 key = { link . href }
5078 href = { link . href }
5179 onClick = { onNavigate }
80+ aria-current = { isActive ? 'page' : undefined }
5281 className = { cn (
53- 'px-3 py-2 text-sm font-medium transition-colors hover:text-foreground' ,
54- isActive ? 'text-foreground' : 'text-muted-foreground' ,
82+ baseLink ,
83+ isActive ? 'bg-muted text-foreground' : 'text-muted-foreground'
5584 ) }
5685 >
5786 { link . label }
@@ -63,7 +92,7 @@ export function NavLinks({ className, onNavigate, showAdminLink = false }: NavLi
6392 < Link
6493 href = "/shop/admin/products/new"
6594 onClick = { onNavigate }
66- className = "text-sm text-muted-foreground hover:text-foreground"
95+ className = { cn ( baseLink , ' text-muted-foreground' ) }
6796 >
6897 New product
6998 </ Link >
0 commit comments