Skip to content

Commit e35cc09

Browse files
authored
Merge pull request #8703 from TylerAPfledderer/refactor/staking-home-table-of-contents-chakra
Refactor: Migrate `StakingHomeTableOfContents` to Chakra
2 parents 84151fd + 34217ae commit e35cc09

File tree

1 file changed

+19
-54
lines changed

1 file changed

+19
-54
lines changed

src/components/Staking/StakingHomeTableOfContents.tsx

Lines changed: 19 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import React from "react"
2-
import { motion } from "framer-motion"
3-
import { Link } from "gatsby"
4-
import styled from "@emotion/styled"
5-
6-
const StyledTableOfContentsLink = styled(Link)`
7-
position: relative;
8-
display: inline-block;
9-
color: ${({ theme }) => theme.colors.text300};
10-
margin-bottom: 0.5rem !important;
11-
`
2+
import { Link as GatsbyLink } from "gatsby"
3+
import { Box, List, ListItem } from "@chakra-ui/react"
4+
import Link from "../Link"
125

136
interface Item {
147
id: string
@@ -23,50 +16,22 @@ const TableOfContentsLink: React.FC<ITableOfContentsLinkProps> = ({
2316
item: { id, title },
2417
}) => {
2518
const url = `#${id}`
26-
let isActive = false
27-
if (typeof window !== `undefined`) {
28-
isActive = window.location.hash === url
29-
}
30-
// const isNested = depth === 2
31-
let classes = "nested"
32-
if (isActive) {
33-
classes += " active"
34-
}
19+
3520
return (
36-
<StyledTableOfContentsLink to={url} className={classes}>
21+
<Link
22+
as={GatsbyLink}
23+
to={url}
24+
position="relative"
25+
display="inline-block"
26+
color="text300"
27+
// `li :last-child` global selector wants to override this without `!important`
28+
mb="0.5rem !important"
29+
>
3730
{title}
38-
</StyledTableOfContentsLink>
31+
</Link>
3932
)
4033
}
4134

42-
const OuterList = styled(motion.ul)`
43-
list-style-type: none;
44-
list-style-image: none;
45-
padding: 0;
46-
margin: 0;
47-
font-size: 1.25rem;
48-
text-align: right;
49-
line-height: 1.6;
50-
font-weight: 400;
51-
padding-right: 0.25rem;
52-
padding-left: 1rem;
53-
54-
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
55-
display: none;
56-
}
57-
`
58-
59-
const Aside = styled.aside`
60-
padding: 0rem;
61-
text-align: right;
62-
margin-bottom: 2rem;
63-
overflow-y: auto;
64-
`
65-
66-
const ListItem = styled.li`
67-
margin: 0;
68-
`
69-
7035
export interface IProps {
7136
items: Array<Item>
7237
}
@@ -75,17 +40,17 @@ const StakingHomeTableOfContents: React.FC<IProps> = ({ items }) => {
7540
if (!items) return null
7641

7742
return (
78-
<Aside>
79-
<OuterList>
43+
<Box as="nav" p={0} textAlign="right" mb={8} overflowY="auto">
44+
<List fontSize="xl" lineHeight={1.6} fontWeight={400} ps={4} pe={1} m={0}>
8045
{items.map((item, index) => (
81-
<ListItem key={index}>
46+
<ListItem key={index} m={0}>
8247
<div>
8348
<TableOfContentsLink item={item} />
8449
</div>
8550
</ListItem>
8651
))}
87-
</OuterList>
88-
</Aside>
52+
</List>
53+
</Box>
8954
)
9055
}
9156

0 commit comments

Comments
 (0)