nextjs-dashboard/app/ui/dashboard/nav-links.tsx

50 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-10-30 05:07:19 +00:00
"use client";
2023-10-29 23:23:33 +00:00
import {
2023-10-30 05:07:19 +00:00
UserGroupIcon,
HomeIcon,
DocumentDuplicateIcon,
} from "@heroicons/react/24/outline";
import Link from "next/link";
import { usePathname } from "next/navigation";
import clsx from "clsx";
2023-10-29 23:23:33 +00:00
// Map of links to display in the side navigation.
// Depending on the size of the application, this would be stored in a database.
const links = [
2023-10-30 05:07:19 +00:00
{ name: "Home", href: "/dashboard", icon: HomeIcon },
{
name: "Invoices",
href: "/dashboard/invoices",
icon: DocumentDuplicateIcon,
},
{ name: "Customers", href: "/dashboard/customers", icon: UserGroupIcon },
2023-10-29 23:23:33 +00:00
];
export default function NavLinks() {
2023-10-30 05:07:19 +00:00
const pathname = usePathname();
return (
<>
{links.map((link) => {
const LinkIcon = link.icon;
return (
<Link
key={link.name}
href={link.href}
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>
);
})}
</>
);
2023-10-29 23:23:33 +00:00
}