|
|
|
@ -1,5 +1,6 @@
|
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
|
import { Fragment } from 'react';
|
|
|
|
|
import { Menu, Transition } from '@headlessui/react';
|
|
|
|
|
import { ChevronDownIcon } from '@heroicons/react/20/solid';
|
|
|
|
@ -8,6 +9,7 @@ type NavigationItem = Readonly<{
|
|
|
|
|
children?: ReadonlyArray<NavigationItem>;
|
|
|
|
|
href: string;
|
|
|
|
|
name: string;
|
|
|
|
|
target?: '_blank';
|
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
|
|
|
|
@ -15,15 +17,21 @@ export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
|
|
|
|
|
type Props = Readonly<{
|
|
|
|
|
items: ProductNavigationItems;
|
|
|
|
|
title: string;
|
|
|
|
|
titleHref: string;
|
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
export default function ProductNavigation({ items, title }: Props) {
|
|
|
|
|
export default function ProductNavigation({ items, title, titleHref }: Props) {
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<nav aria-label="Global" className="flex space-x-8">
|
|
|
|
|
<span className="text-primary-700 text-sm font-medium">{title}</span>
|
|
|
|
|
<div className="hidden space-x-8 md:flex">
|
|
|
|
|
{items.map((item) =>
|
|
|
|
|
item.children != null && item.children.length > 0 ? (
|
|
|
|
|
<nav aria-label="Global" className="flex h-full items-center space-x-8">
|
|
|
|
|
<Link className="text-primary-700 text-sm font-medium" href={titleHref}>
|
|
|
|
|
{title}
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="hidden h-full items-center space-x-8 md:flex">
|
|
|
|
|
{items.map((item) => {
|
|
|
|
|
const isActive = router.pathname === item.href;
|
|
|
|
|
return item.children != null && item.children.length > 0 ? (
|
|
|
|
|
<Menu key={item.name} as="div" className="relative text-left">
|
|
|
|
|
<Menu.Button className="focus:ring-primary-600 flex items-center rounded-md text-sm font-medium text-slate-900 focus:outline-none focus:ring-2 focus:ring-offset-2">
|
|
|
|
|
<span>{item.name}</span>
|
|
|
|
@ -63,12 +71,15 @@ export default function ProductNavigation({ items, title }: Props) {
|
|
|
|
|
) : (
|
|
|
|
|
<Link
|
|
|
|
|
key={item.name}
|
|
|
|
|
className="hover:text-primary-600 text-sm font-medium text-slate-900"
|
|
|
|
|
className={clsx(
|
|
|
|
|
'hover:text-primary-600 inline-flex h-full items-center border-y-2 border-t-transparent text-sm font-medium text-slate-900',
|
|
|
|
|
isActive ? 'border-b-primary-500' : 'border-b-transparent',
|
|
|
|
|
)}
|
|
|
|
|
href={item.href}>
|
|
|
|
|
{item.name}
|
|
|
|
|
</Link>
|
|
|
|
|
),
|
|
|
|
|
)}
|
|
|
|
|
);
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|