1
1
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"
12
5
13
6
interface Item {
14
7
id : string
@@ -23,50 +16,22 @@ const TableOfContentsLink: React.FC<ITableOfContentsLinkProps> = ({
23
16
item : { id, title } ,
24
17
} ) => {
25
18
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
+
35
20
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
+ >
37
30
{ title }
38
- </ StyledTableOfContentsLink >
31
+ </ Link >
39
32
)
40
33
}
41
34
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
-
70
35
export interface IProps {
71
36
items : Array < Item >
72
37
}
@@ -75,17 +40,17 @@ const StakingHomeTableOfContents: React.FC<IProps> = ({ items }) => {
75
40
if ( ! items ) return null
76
41
77
42
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 } >
80
45
{ items . map ( ( item , index ) => (
81
- < ListItem key = { index } >
46
+ < ListItem key = { index } m = { 0 } >
82
47
< div >
83
48
< TableOfContentsLink item = { item } />
84
49
</ div >
85
50
</ ListItem >
86
51
) ) }
87
- </ OuterList >
88
- </ Aside >
52
+ </ List >
53
+ </ Box >
89
54
)
90
55
}
91
56
0 commit comments