diff --git a/src/components/navigation/Categories.tsx b/src/components/navigation/Categories.tsx index 6a50c57..19286a8 100644 --- a/src/components/navigation/Categories.tsx +++ b/src/components/navigation/Categories.tsx @@ -1,7 +1,6 @@ "use client"; -import { Link } from "@/components/core/Link"; -import { generateCategoryRoute } from "@/misc/navigation"; +import { CategoryLink } from "@/components/navigation/CategoryLink"; import { classNames } from "@/misc/styles"; import { Category } from "@/queries/categories/data"; import { Popover, Transition } from "@headlessui/react"; @@ -20,7 +19,7 @@ export const Categories: React.FC = ({ categories }) => {
{categories.map((category) => ( - {({ open }) => ( + {({ open, close }) => ( <>
= ({ categories }) => {
- - {category.name} - +
    = ({ categories }) => { > {category.children.map((subCategory) => (
  • - - {subCategory.name} - +
  • ))}
diff --git a/src/components/navigation/CategoryLink.tsx b/src/components/navigation/CategoryLink.tsx new file mode 100644 index 0000000..4bd8637 --- /dev/null +++ b/src/components/navigation/CategoryLink.tsx @@ -0,0 +1,38 @@ +import { Link } from "@/components/core/Link"; +import { generateCategoryRoute } from "@/misc/navigation"; +import { match } from "ts-pattern"; + +type Props = { + variant: "main" | "sub"; + slug: string; + name: string; + onClick?: () => void; +}; + +/** + * + */ +export const CategoryLink: React.FC = ({ + variant, + slug, + name, + onClick, +}) => { + const route = generateCategoryRoute(slug); + + return ( + "text-lg font-medium text-gray-900") + .with( + "sub", + () => "text-gray-500 hover:text-gray-800 text-sm font-medium" + ) + .exhaustive()} + onClick={onClick} + > + {name} + + ); +}; diff --git a/src/components/navigation/MobileNavbar.tsx b/src/components/navigation/MobileNavbar.tsx index 444c7b9..ce1d1c8 100644 --- a/src/components/navigation/MobileNavbar.tsx +++ b/src/components/navigation/MobileNavbar.tsx @@ -1,8 +1,7 @@ "use client"; import { CloseIcon } from "@/components/core/Icon"; -import { Link } from "@/components/core/Link"; -import { generateCategoryRoute } from "@/misc/navigation"; +import { CategoryLink } from "@/components/navigation/CategoryLink"; import { Category } from "@/queries/categories/data"; import { Dialog, Transition } from "@headlessui/react"; import { Fragment } from "react"; @@ -62,13 +61,12 @@ export const MobileNavbar: React.FC = ({
    {categories.map((category) => (
  • - setOpen(false)} - > - {category.name} - + />
      = ({ > {category.children.map((subCategory) => (
    • - setOpen(false)} - > - {subCategory.name} - + />
    • ))}