1
- import { Box , List , ListItem } from "@chakra-ui/react"
2
-
3
1
import type { ToCItem } from "@/lib/types"
4
2
5
- import { BaseLink } from "@/components/Link"
6
3
import { ItemsListProps } from "@/components/TableOfContents/ItemsList"
4
+ import { BaseLink } from "@/components/ui/Link"
7
5
6
+ import { cn } from "@/lib/utils/cn"
8
7
import { trimmedTitle } from "@/lib/utils/toc"
9
8
10
9
export type TableOfContentsLinkProps = {
@@ -19,25 +18,13 @@ const TableOfContentsLink = ({
19
18
isActive = window . location . hash === url
20
19
}
21
20
22
- const classes = isActive ? "active" : ""
23
-
24
21
return (
25
22
< BaseLink
26
23
href = { url }
27
- className = { classes }
28
- position = "relative"
29
- display = "inline-block"
30
- // `li :last-child` global selector wants to override this without `!important`
31
- mb = "4 !important"
32
- textDecoration = "none"
33
- color = "body.medium"
34
- fontWeight = "normal"
35
- fontSize = "xl"
36
- _hover = { {
37
- color : "primary.hover" ,
38
- textDecoration : "none" ,
39
- } }
40
- _visited = { { } }
24
+ className = { cn (
25
+ "relative !mb-4 inline-block text-xl font-normal text-gray-500 no-underline hover:text-primary hover:no-underline dark:text-gray-400" ,
26
+ isActive && "text-primary"
27
+ ) }
41
28
>
42
29
{ trimmedTitle ( title ) }
43
30
</ BaseLink >
@@ -50,9 +37,9 @@ const ItemsList = ({ items, depth, maxDepth }: ItemsListProps) => {
50
37
return (
51
38
< >
52
39
{ items . map ( ( item , index ) => (
53
- < ListItem m = { 0 } key = { index } >
40
+ < li key = { index } className = "m-0" >
54
41
< TableOfContentsLink item = { item } />
55
- </ ListItem >
42
+ </ li >
56
43
) ) }
57
44
</ >
58
45
)
@@ -67,17 +54,11 @@ const UpgradeTableOfContents = ({
67
54
items,
68
55
maxDepth = 1 ,
69
56
} : UpgradeTableOfContentsProps ) => (
70
- < Box
71
- as = "nav"
72
- p = { 0 }
73
- mb = { 8 }
74
- overflowY = "auto"
75
- display = { { base : "none" , l : "block" } }
76
- >
77
- < List m = { 0 } py = { 0 } lineHeight = "1.4" >
57
+ < nav className = "mb-8 hidden overflow-y-auto p-0 lg:block" >
58
+ < ul className = "m-0 py-0 leading-relaxed" >
78
59
< ItemsList items = { items } depth = { 0 } maxDepth = { maxDepth } />
79
- </ List >
80
- </ Box >
60
+ </ ul >
61
+ </ nav >
81
62
)
82
63
83
64
export default UpgradeTableOfContents
0 commit comments