Files
sign/packages/ui/components/breadcrumb/breadcrumb.tsx

49 lines
1.5 KiB
TypeScript
Raw Normal View History

2023-02-03 12:18:55 +01:00
import React from "react";
2023-02-03 13:06:26 +01:00
import Link from "next/link";
2023-04-04 22:02:32 +00:00
import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/20/solid";
2023-02-03 12:18:55 +01:00
export function Breadcrumb(props: any) {
return (
<>
<nav className="sm:hidden" aria-label="Back">
2023-02-03 13:06:26 +01:00
<Link
2023-04-04 22:10:30 +00:00
href={
props.items.length > 1 ? props.items[props.items.length - 2].href : props.items[0].href
}
2023-04-04 22:02:32 +00:00
className="flex items-center text-sm font-medium text-gray-500 hover:text-gray-700">
2023-04-04 22:10:30 +00:00
<ChevronLeftIcon
className="-ml-1 mr-1 h-5 w-5 flex-shrink-0 text-gray-400"
aria-hidden="true"
/>
2023-02-03 12:18:55 +01:00
Back
2023-02-03 13:06:26 +01:00
</Link>
2023-02-03 12:18:55 +01:00
</nav>
<nav className="hidden sm:flex" aria-label="Breadcrumb">
<ol role="list" className="flex items-center space-x-4">
2023-02-03 13:06:26 +01:00
{props?.items.map((item: any, index: number) => (
2023-02-03 13:18:40 +01:00
<React.Fragment key={item.href}>
2023-02-03 13:06:26 +01:00
{index > 0 ? (
2023-04-04 22:10:30 +00:00
<ChevronRightIcon
className="h-5 w-5 flex-shrink-0 text-gray-400"
aria-hidden="true"
/>
2023-02-03 13:06:26 +01:00
) : (
""
)}
2023-02-03 13:18:40 +01:00
<li>
2023-02-03 13:06:26 +01:00
<div className="flex">
2023-04-04 22:10:30 +00:00
<Link
href={item.href}
className="text-sm font-medium text-gray-500 hover:text-gray-700">
2023-02-03 13:06:26 +01:00
{item.title}
</Link>
</div>
</li>
</React.Fragment>
))}
2023-02-03 12:18:55 +01:00
</ol>
</nav>
</>
);
}