Skip to content

Commit 8278c1b

Browse files
(SP: 1) [UI] Shop header nav: add Home link + align hover/active styling with platform
1 parent 613e346 commit 8278c1b

3 files changed

Lines changed: 60 additions & 21 deletions

File tree

frontend/components/header/AppMobileMenu.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ type Props = {
1616
showAdminLink?: boolean;
1717
};
1818

19-
export function AppMobileMenu({ variant, userExists, showAdminLink = false }: Props) {
19+
export function AppMobileMenu({
20+
variant,
21+
userExists,
22+
showAdminLink = false,
23+
}: Props) {
2024
const [open, setOpen] = useState(false);
2125

2226
const close = () => setOpen(false);
@@ -65,6 +69,16 @@ export function AppMobileMenu({ variant, userExists, showAdminLink = false }: Pr
6569
className="fixed left-0 right-0 top-16 z-50 border-t border-border bg-background px-4 py-4 md:hidden"
6670
>
6771
<div className="flex flex-col gap-1">
72+
{variant === 'shop' ? (
73+
<Link
74+
href="/"
75+
onClick={close}
76+
className="rounded-md px-3 py-2 text-sm font-medium text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
77+
>
78+
Home
79+
</Link>
80+
) : null}
81+
6882
{links.map(link => (
6983
<Link
7084
key={link.href}

frontend/components/header/UnifiedHeader.tsx

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { LogIn, Search, User, Home } from 'lucide-react';
3+
import { LogIn, Search, User } from 'lucide-react';
44
import { Link } from '@/i18n/routing';
55
import { SITE_LINKS } from '@/lib/navigation';
66

@@ -51,9 +51,16 @@ export function UnifiedHeader({
5151
</Link>
5252
</div>
5353

54-
<nav className="hidden items-center justify-center md:flex">
54+
<nav
55+
className="hidden items-center justify-center md:flex"
56+
aria-label="Primary"
57+
>
5558
{isShop ? (
56-
<NavLinks className="md:flex" showAdminLink={showAdminLink} />
59+
<NavLinks
60+
className="md:flex"
61+
showAdminLink={showAdminLink}
62+
includeHomeLink
63+
/>
5764
) : (
5865
<div className="flex items-center gap-1">
5966
{SITE_LINKS.map(link => (
@@ -71,17 +78,6 @@ export function UnifiedHeader({
7178

7279
<div className="flex items-center gap-1">
7380
<div className="hidden items-center gap-2 md:flex">
74-
{isShop ? (
75-
<Link
76-
href="/"
77-
aria-label="Back to main site"
78-
className="flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-secondary hover:text-foreground"
79-
>
80-
<Home className="h-5 w-5" />
81-
</Link>
82-
) : (
83-
<div className="h-9 w-9 flex-shrink-0" aria-hidden="true" />
84-
)}
8581
{isShop && enableSearch ? (
8682
<>
8783
<button

frontend/components/shop/header/nav-links.tsx

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)