|
1 | 1 | import React from "react"
|
2 |
| -import { Box, UnorderedList, ListItem } from "@chakra-ui/react" |
| 2 | +import { |
| 3 | + Breadcrumb, |
| 4 | + BreadcrumbItem, |
| 5 | + BreadcrumbLink, |
| 6 | + BreadcrumbProps, |
| 7 | +} from "@chakra-ui/react" |
3 | 8 | import { useIntl } from "react-intl"
|
4 | 9 |
|
5 | 10 | import Link from "./Link"
|
6 |
| -import { isLang, supportedLanguages } from "../utils/languages" |
| 11 | +import { isLang } from "../utils/languages" |
7 | 12 | import { isTranslationKey, translateMessageId } from "../utils/translations"
|
8 | 13 |
|
9 |
| -export interface IProps { |
| 14 | +export interface IProps extends BreadcrumbProps { |
10 | 15 | slug: string
|
11 | 16 | startDepth?: number
|
12 | 17 | }
|
@@ -49,50 +54,46 @@ const Breadcrumbs: React.FC<IProps> = ({
|
49 | 54 | })
|
50 | 55 |
|
51 | 56 | return (
|
52 |
| - <Box |
53 |
| - aria-label="Breadcrumb" |
| 57 | + <Breadcrumb |
54 | 58 | dir="auto"
|
55 |
| - {...restProps} |
56 |
| - as="nav" |
57 |
| - marginBottom={8} |
58 |
| - listStyleType="none" |
59 | 59 | position="relative"
|
60 |
| - zIndex={1} |
| 60 | + zIndex="1" |
| 61 | + mb={8} |
| 62 | + sx={{ |
| 63 | + // TODO: Move this to `listProps` upon upgrading `@chakra-ui/react` |
| 64 | + // to at least v2.4.2 |
| 65 | + ol: { |
| 66 | + m: 0, |
| 67 | + lineHeight: 1, |
| 68 | + }, |
| 69 | + }} |
| 70 | + {...restProps} |
61 | 71 | >
|
62 |
| - <UnorderedList |
63 |
| - display="flex" |
64 |
| - flexWrap="wrap" |
65 |
| - listStyleType="none" |
66 |
| - margin={0} |
67 |
| - > |
68 |
| - {crumbs.map((crumb, idx) => ( |
69 |
| - <ListItem |
| 72 | + {crumbs.map((crumb, idx) => { |
| 73 | + const isCurrentPage = slug === crumb.fullPath |
| 74 | + return ( |
| 75 | + <BreadcrumbItem |
70 | 76 | key={idx}
|
71 |
| - margin={0} |
72 |
| - marginRight={2} |
| 77 | + isCurrentPage={isCurrentPage} |
| 78 | + color="textTableOfContents" |
73 | 79 | fontSize="sm"
|
74 |
| - lineHeight="140%" |
75 | 80 | letterSpacing="wider"
|
| 81 | + lineHeight="140%" |
| 82 | + m={0} |
76 | 83 | >
|
77 |
| - <Link |
| 84 | + <BreadcrumbLink |
| 85 | + as={Link} |
78 | 86 | to={crumb.fullPath}
|
79 |
| - isPartiallyActive={slug === crumb.fullPath} |
80 |
| - textDecoration="none" |
81 |
| - color="textTableOfContents" |
| 87 | + isPartiallyActive={isCurrentPage} |
82 | 88 | _hover={{ color: "primary", textDecor: "none" }}
|
83 | 89 | _active={{ color: "primary" }}
|
84 | 90 | >
|
85 | 91 | {crumb.text}
|
86 |
| - </Link> |
87 |
| - {idx < crumbs.length - 1 && ( |
88 |
| - <Box as="span" marginLeft={2} color="textTableOfContents"> |
89 |
| - / |
90 |
| - </Box> |
91 |
| - )} |
92 |
| - </ListItem> |
93 |
| - ))} |
94 |
| - </UnorderedList> |
95 |
| - </Box> |
| 92 | + </BreadcrumbLink> |
| 93 | + </BreadcrumbItem> |
| 94 | + ) |
| 95 | + })} |
| 96 | + </Breadcrumb> |
96 | 97 | )
|
97 | 98 | }
|
98 | 99 |
|
|
0 commit comments