Skip to content

Commit 346303e

Browse files
authored
Only apply active styles to active link in app header nav links (#17)
1 parent 70085d4 commit 346303e

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

resources/js/components/app-header.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ interface AppHeaderProps {
4343
}
4444

4545
export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
46-
const { auth } = usePage<SharedData>().props;
46+
const page = usePage<SharedData>();
47+
const { auth } = page.props;
4748
const getInitials = useInitials();
4849
return (
4950
<>
@@ -105,12 +106,18 @@ export function AppHeader({ breadcrumbs = [] }: AppHeaderProps) {
105106
<NavigationMenuItem key={index} className="relative flex h-full items-center">
106107
<Link
107108
href={item.url}
108-
className={cn(navigationMenuTriggerStyle(), activeItemStyles, 'h-9 cursor-pointer px-3')}
109+
className={cn(
110+
navigationMenuTriggerStyle(),
111+
page.url === item.url && activeItemStyles,
112+
'h-9 cursor-pointer px-3',
113+
)}
109114
>
110115
{item.icon && <Icon iconNode={item.icon} className="mr-2 h-4 w-4" />}
111116
{item.title}
112117
</Link>
113-
<div className="absolute bottom-0 left-0 h-0.5 w-full translate-y-px bg-black dark:bg-white"></div>
118+
{page.url === item.url && (
119+
<div className="absolute bottom-0 left-0 h-0.5 w-full translate-y-px bg-black dark:bg-white"></div>
120+
)}
114121
</NavigationMenuItem>
115122
))}
116123
</NavigationMenuList>

0 commit comments

Comments
 (0)