subman-nextjs/src/app/ui/navLinks.tsx

41 lines
1.5 KiB
TypeScript
Raw Normal View History

2024-06-20 18:02:25 +00:00
"use client"
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ComponentProps } from "react";
import clsx from "clsx";
2024-06-24 09:55:31 +00:00
import { twMerge } from "tailwind-merge";
2024-09-21 15:23:31 +00:00
import { ArrowUpNarrowWide, BookOpen, BookOpenText } from "lucide-react";
2024-06-20 18:02:25 +00:00
function NavLink(props: ComponentProps<"div"> & { href: string }) {
return (
<Link href={props.href}><h1 className={props.className}>{props.children}</h1></Link>
)
}
export default function Navlinks(props: ComponentProps<"div">) {
const pathname = usePathname()
const links = [
2024-09-21 15:23:31 +00:00
{ link: "/story", label: "STORIES", icon: <BookOpenText /> },
{ link: "/publication", label: "PUBLICATIONS", icon: <BookOpen /> },
{ link: "/submission", label: "SUBMISSIONS", icon: <ArrowUpNarrowWide /> },
2024-06-20 18:02:25 +00:00
]
return (
2024-06-22 16:12:55 +00:00
<div className={props.className}>
2024-09-21 15:23:31 +00:00
<div className="text-secondary-foreground flex flex-row md:flex-col" >
2024-06-24 08:27:53 +00:00
{
links.map(e => (<NavLink key={e.link} href={e.link}
2024-09-30 10:06:37 +00:00
className={twMerge(clsx("text-xl drop-shadow font-black my-2 w-full mr-2 p-2 pl-6 antialiased text-secondary-foreground bg-secondary rounded-3xl md:rounded-l-3xl ",
2024-06-24 08:27:53 +00:00
{
2024-06-24 09:55:31 +00:00
"text-primary-foreground bg-primary": pathname.includes(e.link)
2024-06-24 08:27:53 +00:00
}
2024-06-24 09:55:31 +00:00
))}
2024-09-21 15:23:31 +00:00
>
<p className="drop-shadow-sm hidden md:block">{e.label}</p>
<span className="block md:hidden">{e.icon}</span>
</NavLink >))
2024-06-24 08:27:53 +00:00
}
</ div>
2024-06-22 16:12:55 +00:00
</div>
2024-06-20 18:02:25 +00:00
)
}