Skip to content

Commit 6cc66a7

Browse files
authored
Merge pull request #13974 from ethereum/updateTableOfContents
Migrate UpgradeTableOfContents to Shadcn
2 parents 8a0e613 + 3232008 commit 6cc66a7

File tree

1 file changed

+12
-31
lines changed

1 file changed

+12
-31
lines changed
Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { Box, List, ListItem } from "@chakra-ui/react"
2-
31
import type { ToCItem } from "@/lib/types"
42

5-
import { BaseLink } from "@/components/Link"
63
import { ItemsListProps } from "@/components/TableOfContents/ItemsList"
4+
import { BaseLink } from "@/components/ui/Link"
75

6+
import { cn } from "@/lib/utils/cn"
87
import { trimmedTitle } from "@/lib/utils/toc"
98

109
export type TableOfContentsLinkProps = {
@@ -19,25 +18,13 @@ const TableOfContentsLink = ({
1918
isActive = window.location.hash === url
2019
}
2120

22-
const classes = isActive ? "active" : ""
23-
2421
return (
2522
<BaseLink
2623
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+
)}
4128
>
4229
{trimmedTitle(title)}
4330
</BaseLink>
@@ -50,9 +37,9 @@ const ItemsList = ({ items, depth, maxDepth }: ItemsListProps) => {
5037
return (
5138
<>
5239
{items.map((item, index) => (
53-
<ListItem m={0} key={index}>
40+
<li key={index} className="m-0">
5441
<TableOfContentsLink item={item} />
55-
</ListItem>
42+
</li>
5643
))}
5744
</>
5845
)
@@ -67,17 +54,11 @@ const UpgradeTableOfContents = ({
6754
items,
6855
maxDepth = 1,
6956
}: 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">
7859
<ItemsList items={items} depth={0} maxDepth={maxDepth} />
79-
</List>
80-
</Box>
60+
</ul>
61+
</nav>
8162
)
8263

8364
export default UpgradeTableOfContents

0 commit comments

Comments
 (0)