|
|
@ -1,5 +1,6 @@
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import Link from 'next/link';
|
|
|
|
import Link from 'next/link';
|
|
|
|
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import { Fragment } from 'react';
|
|
|
|
import { Fragment } from 'react';
|
|
|
|
import { Menu, Transition } from '@headlessui/react';
|
|
|
|
import { Menu, Transition } from '@headlessui/react';
|
|
|
|
import { ChevronDownIcon } from '@heroicons/react/20/solid';
|
|
|
|
import { ChevronDownIcon } from '@heroicons/react/20/solid';
|
|
|
@ -8,6 +9,7 @@ type NavigationItem = Readonly<{
|
|
|
|
children?: ReadonlyArray<NavigationItem>;
|
|
|
|
children?: ReadonlyArray<NavigationItem>;
|
|
|
|
href: string;
|
|
|
|
href: string;
|
|
|
|
name: string;
|
|
|
|
name: string;
|
|
|
|
|
|
|
|
target?: '_blank';
|
|
|
|
}>;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
|
|
export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
|
|
|
|
export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
|
|
|
@ -15,15 +17,21 @@ export type ProductNavigationItems = ReadonlyArray<NavigationItem>;
|
|
|
|
type Props = Readonly<{
|
|
|
|
type Props = Readonly<{
|
|
|
|
items: ProductNavigationItems;
|
|
|
|
items: ProductNavigationItems;
|
|
|
|
title: string;
|
|
|
|
title: string;
|
|
|
|
|
|
|
|
titleHref: string;
|
|
|
|
}>;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
|
|
|
|
export default function ProductNavigation({ items, title }: Props) {
|
|
|
|
export default function ProductNavigation({ items, title, titleHref }: Props) {
|
|
|
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<nav aria-label="Global" className="flex space-x-8">
|
|
|
|
<nav aria-label="Global" className="flex h-full items-center space-x-8">
|
|
|
|
<span className="text-primary-700 text-sm font-medium">{title}</span>
|
|
|
|
<Link className="text-primary-700 text-sm font-medium" href={titleHref}>
|
|
|
|
<div className="hidden space-x-8 md:flex">
|
|
|
|
{title}
|
|
|
|
{items.map((item) =>
|
|
|
|
</Link>
|
|
|
|
item.children != null && item.children.length > 0 ? (
|
|
|
|
<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 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">
|
|
|
|
<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>
|
|
|
|
<span>{item.name}</span>
|
|
|
@ -63,12 +71,15 @@ export default function ProductNavigation({ items, title }: Props) {
|
|
|
|
) : (
|
|
|
|
) : (
|
|
|
|
<Link
|
|
|
|
<Link
|
|
|
|
key={item.name}
|
|
|
|
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}>
|
|
|
|
href={item.href}>
|
|
|
|
{item.name}
|
|
|
|
{item.name}
|
|
|
|
</Link>
|
|
|
|
</Link>
|
|
|
|
),
|
|
|
|
);
|
|
|
|
)}
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</nav>
|
|
|
|
</nav>
|
|
|
|
);
|
|
|
|
);
|
|
|
|