Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions client/src/app/test/breadcrumb/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import Breadcrumb from "@/components/ui/breadcrumb";

export default function TestPage() {
return (
<div className="space-y-8 p-6">
<h1 className="text-2xl font-bold">Breadcrumb Test</h1>

<Breadcrumb
items={[
{ label: "Find my booking", href: "/" },
{ label: "List of Bookings" },
]}
/>
</div>
);
}
48 changes: 48 additions & 0 deletions client/src/components/ui/breadcrumb.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import Link from "next/link";
import React from "react";

export type BreadcrumbItem = {
label: string;
href?: string;
};

type BreadcrumbProps = {
items: BreadcrumbItem[];
className?: string;
};

const Breadcrumb: React.FC<BreadcrumbProps> = ({ items, className }) => {
if (!items?.length) return null;

return (
<nav aria-label="Breadcrumb" className={className}>
<ul className="flex flex-wrap items-center gap-2 text-sm">
{items.map((item, i) => {
const last = i === items.length - 1;

return (
<li key={`${item.label}-${i}`} className="flex items-center gap-2">
{!last && item.href ? (
<Link
href={item.href}
className="underline-offset-2 hover:underline"
>
{item.label}
</Link>
) : (
<span
style={last ? { color: "var(--bloom-orbit)" } : undefined}
>
{item.label}
</span>
)}
{!last && <span>/</span>}
</li>
);
})}
</ul>
</nav>
);
};

export default Breadcrumb;