-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBreadcrumbs.tsx
More file actions
49 lines (45 loc) · 1.3 KB
/
Breadcrumbs.tsx
File metadata and controls
49 lines (45 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import React from "react";
import { BreadcrumbsProps } from "./Breadcrumbs.types";
import { LinkWithRef } from "../LinkWithRef";
const Breadcrumbs: React.FC<BreadcrumbsProps> = (props) => {
const { items, className, collapseOnMobile, ...attributes } = props;
const breadcrumbs = items
? items.map((item, index) => {
const { href, to, reactListKey, children, ...itemAttributes } = item;
return href || to ? (
<li
key={reactListKey || index}
className="govuk-breadcrumbs__list-item"
>
<LinkWithRef
href={href}
to={to}
className="govuk-breadcrumbs__link"
{...itemAttributes}
>
{children}
</LinkWithRef>
</li>
) : (
<li
key={reactListKey || index}
className="govuk-breadcrumbs__list-item"
aria-current="page"
>
{children}
</li>
);
})
: null;
return (
<div
className={`govuk-breadcrumbs ${className || ""} ${
collapseOnMobile ? "govuk-breadcrumbs--collapse-on-mobile" : ""
}`}
{...attributes}
>
<ol className="govuk-breadcrumbs__list">{breadcrumbs}</ol>
</div>
);
};
export default Breadcrumbs;