Skip to content

Commit 129453c

Browse files
committed
Migrate Leaderboard.tsx to Shadcn
1 parent 2f63ede commit 129453c

File tree

1 file changed

+20
-68
lines changed

1 file changed

+20
-68
lines changed

src/components/Leaderboard.tsx

Lines changed: 20 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
import { useTranslation } from "next-i18next"
2-
import {
3-
Avatar,
4-
Box,
5-
Flex,
6-
LinkBox,
7-
LinkOverlay,
8-
List,
9-
ListItem,
10-
useColorModeValue,
11-
VisuallyHidden,
12-
} from "@chakra-ui/react"
2+
import { VisuallyHidden } from "@radix-ui/react-visually-hidden"
133

144
import Emoji from "@/components/Emoji"
15-
import { BaseLink } from "@/components/Link"
165

176
import { GITHUB_URL } from "@/lib/constants"
187

8+
import { Avatar } from "./ui/avatar"
9+
import { Flex } from "./ui/flex"
10+
import { LinkBox } from "./ui/link-box"
11+
import { LinkOverlay } from "./ui/link-box"
12+
import { List, ListItem } from "./ui/list"
13+
1914
import { useRtlFlip } from "@/hooks/useRtlFlip"
2015

2116
type Person = {
@@ -30,29 +25,12 @@ type LeaderboardProps = {
3025
}
3126

3227
const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
33-
const { flipForRtl } = useRtlFlip()
34-
const colorModeStyles = useColorModeValue(
35-
{
36-
listBoxShadow: "tableBox.light",
37-
linkBoxShadow: "tableItemBox.light",
38-
scoreColor: "blackAlpha.700",
39-
},
40-
{
41-
listBoxShadow: "tableBox.dark",
42-
linkBoxShadow: "tableItemBox.dark",
43-
scoreColor: "whiteAlpha.600",
44-
}
45-
)
46-
28+
const { twFlipForRtl } = useRtlFlip()
4729
const { t } = useTranslation("page-bug-bounty")
4830

4931
return (
5032
<List
51-
bgColor="background.base"
52-
boxShadow={colorModeStyles.listBoxShadow}
53-
w="100%"
54-
mb={8}
55-
ms={0}
33+
className="mb-8 ms-0 w-full list-none bg-background shadow-table-box"
5634
aria-label={t("page-upgrades-bug-bounty-leaderboard-list")}
5735
>
5836
{content
@@ -72,41 +50,22 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
7250
}
7351

7452
return (
75-
<ListItem key={username} mb={0}>
53+
<ListItem className="mb-0" key={username}>
7654
<LinkBox
55+
className="mb-1 flex w-full items-center justify-between p-4 shadow-table-item-box hover:rounded-lg hover:bg-background-highlight hover:no-underline hover:shadow-primary"
7756
key={idx}
78-
display="flex"
79-
justifyContent="space-between"
80-
alignItems="center"
81-
boxShadow={colorModeStyles.linkBoxShadow}
82-
mb={0.25}
83-
p={4}
84-
w="100%"
85-
_hover={{
86-
textDecor: "none",
87-
borderRadius: 0.5,
88-
boxShadow: "0 0 1px var(--eth-colors-primary-base)",
89-
background: "tableBackgroundHover",
90-
}}
9157
>
92-
<Box me={4} opacity="0.4">
93-
{idx + 1}
94-
</Box>
58+
<div className="me-4 opacity-40">{idx + 1}</div>
9559
<Avatar
60+
className="me-4 flex h-10 w-10 flex-wrap sm:block"
61+
href={avatarImg}
9662
src={avatarImg}
9763
name={avatarAlt}
98-
me={4}
99-
h={10}
100-
w={10}
101-
display={{ base: "none", xs: "block" }}
10264
/>
103-
<Flex flex="1 1 75%" direction="column" me={8}>
65+
<Flex className="me-8 flex-1 basis-3/4 flex-col">
10466
<LinkOverlay
105-
as={BaseLink}
67+
className="text-body no-underline"
10668
href={hasGitHub ? `${GITHUB_URL}${username}` : "#"}
107-
textDecor="none"
108-
color="text"
109-
hideArrow
11069
>
11170
<VisuallyHidden>{`In place number ${
11271
idx + 1
@@ -117,20 +76,13 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
11776
)}
11877
</LinkOverlay>
11978

120-
<Box fontSize="sm" color={colorModeStyles.scoreColor}>
79+
<div className="text-sm text-body-medium">
12180
{score} {t("page-upgrades-bug-bounty-leaderboard-points")}
122-
</Box>
81+
</div>
12382
</Flex>
12483
{emoji && <Emoji className="me-8 text-2xl" text={emoji} />}
125-
<Box
126-
as="span"
127-
_after={{
128-
content: '"↗"',
129-
ms: 0.5,
130-
me: 1.5,
131-
transform: flipForRtl,
132-
display: "inline-block",
133-
}}
84+
<span
85+
className={`after:me-1.5 after:ms-0.5 after:content-['↗'] after:${twFlipForRtl} after:inline-block`}
13486
/>
13587
</LinkBox>
13688
</ListItem>

0 commit comments

Comments
 (0)