|
1 | 1 | import React from "react"
|
2 |
| -import styled from "@emotion/styled" |
3 | 2 | import { useTranslation } from "gatsby-plugin-react-i18next"
|
| 3 | +import { Box, UnorderedList, ListItem } from "@chakra-ui/react" |
4 | 4 |
|
5 | 5 | import Link from "./Link"
|
6 | 6 | import { isLang } from "../utils/languages"
|
7 | 7 | import { isTranslationKey } from "../utils/translations"
|
8 | 8 |
|
9 |
| -const ListContainer = styled.nav` |
10 |
| - margin-bottom: 2rem; |
11 |
| - list-style-type: none; |
12 |
| - /* Avoid header overlap: */ |
13 |
| - position: relative; |
14 |
| - z-index: 1; |
15 |
| -` |
16 |
| - |
17 |
| -const List = styled.ol` |
18 |
| - margin: 0; |
19 |
| - list-style-type: none; |
20 |
| - display: flex; |
21 |
| - flex-wrap: wrap; |
22 |
| -` |
23 |
| - |
24 |
| -const ListItem = styled.li` |
25 |
| - margin: 0; |
26 |
| - margin-right: 0.5rem; |
27 |
| - font-size: 0.875rem; |
28 |
| - line-height: 140%; |
29 |
| - letter-spacing: 0.04em; |
30 |
| -` |
31 |
| - |
32 |
| -const Slash = styled.span` |
33 |
| - margin-left: 0.5rem; |
34 |
| - color: ${(props) => props.theme.colors.textTableOfContents}; |
35 |
| -` |
36 |
| - |
37 |
| -const CrumbLink = styled(Link)` |
38 |
| - text-decoration: none; |
39 |
| - color: ${(props) => props.theme.colors.textTableOfContents}; |
40 |
| -
|
41 |
| - &:hover { |
42 |
| - text-decoration: none; |
43 |
| - color: ${(props) => props.theme.colors.primary}; |
44 |
| - } |
45 |
| -
|
46 |
| - &.active { |
47 |
| - color: ${(props) => props.theme.colors.primary}; |
48 |
| - } |
49 |
| -` |
50 |
| - |
51 | 9 | export interface IProps {
|
52 | 10 | slug: string
|
53 | 11 | startDepth?: number
|
@@ -91,21 +49,50 @@ const Breadcrumbs: React.FC<IProps> = ({
|
91 | 49 | })
|
92 | 50 |
|
93 | 51 | return (
|
94 |
| - <ListContainer aria-label="Breadcrumb" dir="auto" {...restProps}> |
95 |
| - <List> |
| 52 | + <Box |
| 53 | + aria-label="Breadcrumb" |
| 54 | + dir="auto" |
| 55 | + {...restProps} |
| 56 | + as="nav" |
| 57 | + marginBottom={8} |
| 58 | + listStyleType="none" |
| 59 | + position="relative" |
| 60 | + zIndex={1} |
| 61 | + > |
| 62 | + <UnorderedList |
| 63 | + display="flex" |
| 64 | + flexWrap="wrap" |
| 65 | + listStyleType="none" |
| 66 | + margin={0} |
| 67 | + > |
96 | 68 | {crumbs.map((crumb, idx) => (
|
97 |
| - <ListItem key={idx}> |
98 |
| - <CrumbLink |
| 69 | + <ListItem |
| 70 | + key={idx} |
| 71 | + margin={0} |
| 72 | + marginRight={2} |
| 73 | + fontSize="sm" |
| 74 | + lineHeight="140%" |
| 75 | + letterSpacing="wider" |
| 76 | + > |
| 77 | + <Link |
99 | 78 | to={crumb.fullPath}
|
100 | 79 | isPartiallyActive={slug === crumb.fullPath}
|
| 80 | + textDecoration="none" |
| 81 | + color="textTableOfContents" |
| 82 | + _hover={{ color: "primary", textDecor: "none" }} |
| 83 | + _active={{ color: "primary" }} |
101 | 84 | >
|
102 | 85 | {crumb.text}
|
103 |
| - </CrumbLink> |
104 |
| - {idx < crumbs.length - 1 && <Slash>/</Slash>} |
| 86 | + </Link> |
| 87 | + {idx < crumbs.length - 1 && ( |
| 88 | + <Box as="span" marginLeft={2} color="textTableOfContents"> |
| 89 | + / |
| 90 | + </Box> |
| 91 | + )} |
105 | 92 | </ListItem>
|
106 | 93 | ))}
|
107 |
| - </List> |
108 |
| - </ListContainer> |
| 94 | + </UnorderedList> |
| 95 | + </Box> |
109 | 96 | )
|
110 | 97 | }
|
111 | 98 |
|
|
0 commit comments