Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/app/[channel]/(main)/products/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { formatMoney, formatMoneyRange } from "@/lib/utils";
import { CheckoutAddLineDocument, ProductDetailsDocument, ProductListDocument } from "@/gql/graphql";
import * as Checkout from "@/lib/checkout";
import { AvailabilityMessage } from "@/ui/components/AvailabilityMessage";
import { Breadcrumb } from "@/ui/components/nav/components/BreadCrumb";

export async function generateMetadata(
props: {
Expand Down Expand Up @@ -176,6 +177,14 @@ export default async function Page(props: {
__html: JSON.stringify(productJsonLd),
}}
/>
<div>
<Breadcrumb
channel={params.channel}
categoryName={product.category?.name ?? ""}
categorySlug={product.category?.name}
productName={product.name}
/>
</div>
<form className="grid gap-2 sm:grid-cols-2 lg:grid-cols-8" action={addItem}>
<div className="md:col-span-1 lg:col-span-5">
{firstImage && (
Expand Down
1 change: 1 addition & 0 deletions src/graphql/ProductDetails.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ query ProductDetails($slug: String!, $channel: String!) {
category {
id
name
slug
}
variants {
...VariantDetails
Expand Down
48 changes: 48 additions & 0 deletions src/ui/components/nav/components/BreadCrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"use client";

import Link from "next/link";

interface BreadcrumbProps {
channel: string;
categoryName: string;
categorySlug?: string;
productName: string;
}

export function Breadcrumb({ channel, categoryName, categorySlug, productName }: BreadcrumbProps) {
return (
<nav className="mb-4 text-sm text-neutral-500" aria-label="Breadcrumb">
<ol className="flex flex-wrap items-center gap-1">
<li className="flex items-center">
<Link
href={`/${channel}`}
className="transition-colors duration-200 hover:text-neutral-900 hover:underline"
>
Home
</Link>
<span className="mx-1">/</span>
</li>

{categoryName && (
<li className="flex items-center">
{categorySlug ? (
<Link
href={`/${channel}/categories/${categorySlug}`}
className="transition-colors duration-200 hover:text-neutral-900 hover:underline"
>
{categoryName}
</Link>
) : (
<span className="text-neutral-700">{categoryName}</span>
)}
<span className="mx-1">/</span>
</li>
)}

<li className="max-w-xs truncate font-medium text-neutral-900" title={productName}>
{productName}
</li>
</ol>
</nav>
);
}
2 changes: 1 addition & 1 deletion src/ui/components/nav/components/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const MobileMenu = ({ children }: Props) => {
<OpenButton onClick={openMenu} aria-controls="mobile-menu" />
<Transition show={isOpen}>
<Dialog onClose={closeMenu}>
<Dialog.Panel className="fixed inset-0 z-20 flex h-dvh w-screen flex-col overflow-y-scroll">
<Dialog.Panel className="fixed inset-0 z-20 flex h-dvh w-screen flex-col overflow-y-scroll bg-white">
<Transition.Child
className="sticky top-0 z-10 flex h-16 shrink-0 bg-neutral-100/50 px-3 backdrop-blur-md sm:px-8"
enter="motion-safe:transition-all motion-safe:duration-150"
Expand Down