Skip to content

Commit 50662eb

Browse files
authored
Merge pull request #14807 from JoeChenJ/Shadcn_Migrate_Leaderboard.tsx
Shadcn Migrate: Leaderboard.tsx
2 parents a50faff + 583cf01 commit 50662eb

File tree

1 file changed

+16
-63
lines changed

1 file changed

+16
-63
lines changed

src/components/Leaderboard.tsx

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

134
import Emoji from "@/components/Emoji"
14-
import { BaseLink } from "@/components/Link"
155

166
import { GITHUB_URL } from "@/lib/constants"
177

188
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"
1913

2014
import { useRtlFlip } from "@/hooks/useRtlFlip"
2115

@@ -31,29 +25,12 @@ type LeaderboardProps = {
3125
}
3226

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

5031
return (
5132
<List
52-
bgColor="background.base"
53-
boxShadow={colorModeStyles.listBoxShadow}
54-
w="100%"
55-
mb={8}
56-
ms={0}
33+
className="mb-8 ms-0 w-full list-none bg-background shadow-table-box"
5734
aria-label={t("page-upgrades-bug-bounty-leaderboard-list")}
5835
>
5936
{content
@@ -73,26 +50,12 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
7350
}
7451

7552
return (
76-
<ListItem key={username} mb={0}>
53+
<ListItem className="mb-0" key={username}>
7754
<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"
7856
key={idx}
79-
display="flex"
80-
justifyContent="space-between"
81-
alignItems="center"
82-
boxShadow={colorModeStyles.linkBoxShadow}
83-
mb={0.25}
84-
p={4}
85-
w="100%"
86-
_hover={{
87-
textDecor: "none",
88-
borderRadius: 0.5,
89-
boxShadow: "0 0 1px var(--eth-colors-primary-base)",
90-
background: "tableBackgroundHover",
91-
}}
9257
>
93-
<Box me={4} opacity="0.4">
94-
{idx + 1}
95-
</Box>
58+
<div className="me-4 opacity-40">{idx + 1}</div>
9659
<Avatar
9760
src={avatarImg}
9861
name={avatarAlt}
@@ -101,13 +64,10 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
10164
// `size-10` is not part of a "size" variant
10265
className="me-4 size-10"
10366
/>
104-
<Flex flex="1 1 75%" direction="column" me={8}>
67+
<Flex className="me-8 flex-1 basis-3/4 flex-col">
10568
<LinkOverlay
106-
as={BaseLink}
69+
className="text-body no-underline"
10770
href={hasGitHub ? `${GITHUB_URL}${username}` : "#"}
108-
textDecor="none"
109-
color="text"
110-
hideArrow
11171
>
11272
<VisuallyHidden>{`In place number ${
11373
idx + 1
@@ -118,20 +78,13 @@ const Leaderboard = ({ content, limit = 100 }: LeaderboardProps) => {
11878
)}
11979
</LinkOverlay>
12080

121-
<Box fontSize="sm" color={colorModeStyles.scoreColor}>
81+
<div className="text-sm text-body-medium">
12282
{score} {t("page-upgrades-bug-bounty-leaderboard-points")}
123-
</Box>
83+
</div>
12484
</Flex>
12585
{emoji && <Emoji className="me-8 text-2xl" text={emoji} />}
126-
<Box
127-
as="span"
128-
_after={{
129-
content: '"↗"',
130-
ms: 0.5,
131-
me: 1.5,
132-
transform: flipForRtl,
133-
display: "inline-block",
134-
}}
86+
<span
87+
className={`after:me-1.5 after:ms-0.5 after:content-['↗'] after:${twFlipForRtl} after:inline-block`}
13588
/>
13689
</LinkBox>
13790
</ListItem>

0 commit comments

Comments
 (0)