diff --git a/src/components/Breadcrumbs/Breadcrumbs.tsx b/src/components/Breadcrumbs/Breadcrumbs.tsx index 8c5bbf105..291fc73fd 100644 --- a/src/components/Breadcrumbs/Breadcrumbs.tsx +++ b/src/components/Breadcrumbs/Breadcrumbs.tsx @@ -2,7 +2,7 @@ import { Box, BoxProps } from '~/components/Box' import { Divider } from '~/components/Divider' import { Text } from '~/components/Text' -type Path = { +interface Path { label: string url?: string } @@ -12,30 +12,54 @@ type BreadcrumbsProps = BoxProps & { paths: Path[] } -export const Breadcrumbs = ({ - excludeDivider = false, - paths, - ...props -}: BreadcrumbsProps) => { - const lastPath = paths.slice(-1)[0] - const restPaths = paths.slice(0, -1) +export const Breadcrumbs = (props: BreadcrumbsProps) => { + const { paths, excludeDivider = false, ...rest } = props return ( - - - {restPaths.map(({ label, url }, key) => ( - - {label} - {' / '} - - ))} - - - {lastPath.label} - - + + {paths.map((path, idx) => ( + + ))} {!excludeDivider && } ) } + +interface BreadcrumbSegmentProps { + path: Path + active?: boolean +} + +const BreadcrumbSegment = (props: BreadcrumbSegmentProps) => { + const { path, active } = props + + return active ? ( + + {path.label} + + ) : ( + + {path.label} + {' / '} + + ) +}