"use client"
import * as React from "react"
import { Link } from "@/lib/router-compat"
import { cn } from "@/lib/utils"
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb"
export interface PageBreadcrumbTrailItem {
label: string
href?: string
}
export interface PageBreadcrumbBackProps {
/** Destination label (e.g. "Question hub") — shown after the back icon. */
label: string
href: string
className?: string
}
export interface PageBreadcrumbTrailProps {
/** Linkable ancestors (e.g. Question hub). */
items?: PageBreadcrumbTrailItem[]
/**
* Final segment in the trail. Omit when the current page is the `PageHeader`
* `
` — use ancestors-only above the title (no duplicate label).
*/
currentPage?: string
/**
* `header` — SiteHeader: ancestors + `currentPage` on one line.
* `content` — ancestors only, above `PageHeader` title.
*/
variant?: "header" | "content"
className?: string
}
/**
* Single-step back nav — back icon + parent destination (no chevron trail).
* Use in `SiteHeader` for focused child routes (composer, wizard) where the
* page `
` is the current title.
*/
export function PageBreadcrumbBack({ label, href, className }: PageBreadcrumbBackProps) {
return (
{label}
)
}
/**
* Product breadcrumb trail — one component for SiteHeader and in-page shells.
* Uses shadcn `Breadcrumb` primitives with Exxat site-header typography.
*
* For back-icon + parent label only, use {@link PageBreadcrumbBack}.
*/
export function PageBreadcrumbTrail({
items = [],
currentPage,
variant = "content",
className,
}: PageBreadcrumbTrailProps) {
const isHeader = variant === "header"
return (
{items.map((crumb, i) => (
{crumb.href ? (
{crumb.label}
) : (
{crumb.label}
)}
{(currentPage != null || i < items.length - 1) && (
)}
))}
{currentPage != null ? (
{currentPage}
) : null}
)
}