Chapter 5 - Highlight navigation
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
'use client'
|
||||
import {
|
||||
UserGroupIcon,
|
||||
HomeIcon,
|
||||
@@ -5,6 +6,8 @@ import {
|
||||
} from '@heroicons/react/24/outline';
|
||||
|
||||
import Link from 'next/link';
|
||||
import { usePathname } from 'next/navigation';
|
||||
import clsx from 'clsx';
|
||||
|
||||
// Map of links to display in the side navigation.
|
||||
// Depending on the size of the application, this would be stored in a database.
|
||||
@@ -19,6 +22,7 @@ const links = [
|
||||
];
|
||||
|
||||
export default function NavLinks() {
|
||||
const pathname = usePathname();
|
||||
return (
|
||||
<>
|
||||
{links.map((link) => {
|
||||
@@ -27,8 +31,12 @@ export default function NavLinks() {
|
||||
<Link
|
||||
key={link.name}
|
||||
href={link.href}
|
||||
className="flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3"
|
||||
>
|
||||
className={clsx(
|
||||
'flex h-[48px] grow items-center justify-center gap-2 rounded-md bg-gray-50 p-3 text-sm font-medium hover:bg-sky-100 hover:text-blue-600 md:flex-none md:justify-start md:p-2 md:px-3',
|
||||
{
|
||||
'bg-sky-100 text-blue-600': pathname === link.href,
|
||||
},
|
||||
)} >
|
||||
<LinkIcon className="w-6" />
|
||||
<p className="hidden md:block">{link.name}</p>
|
||||
</Link>
|
||||
|
||||
Reference in New Issue
Block a user