Skip to content

Commit f024266

Browse files
authored
Merge pull request #14043 from 0xgun/Shadcn-migrate-StablecoinsTable
feat: migrate StablecoinsTable to shadcn
2 parents 8c3c327 + 07ba537 commit f024266

File tree

1 file changed

+35
-54
lines changed

1 file changed

+35
-54
lines changed

src/components/StablecoinsTable.tsx

Lines changed: 35 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import { useTranslation } from "next-i18next"
2+
3+
import { ButtonLink } from "./ui/buttons/Button"
4+
import { Flex } from "./ui/flex"
25
import {
3-
Flex,
4-
Image,
56
Table,
6-
Tbody,
7-
Td,
8-
Text,
9-
Th,
10-
Thead,
11-
Tr,
12-
} from "@chakra-ui/react"
13-
14-
import { ButtonLink } from "./Buttons"
7+
TableBody,
8+
TableCell,
9+
TableHead,
10+
TableHeader,
11+
TableRow,
12+
} from "./ui/Table"
1513

1614
import { useRtlFlip } from "@/hooks/useRtlFlip"
1715

@@ -45,68 +43,51 @@ const StablecoinsTable = ({
4543
}
4644

4745
return (
48-
<Table variant="unstyled" my={8} bg="background.base" mb={8} minW="720px">
49-
<Thead bg="background.highlight" color="body.medium">
50-
<Tr>
46+
<Table className="my-8 min-w-[720px] bg-background">
47+
<TableHeader>
48+
<TableRow>
5149
{columns.map((column, idx) => (
52-
<Th
53-
key={idx}
54-
fontWeight="bold"
55-
fontSize="md"
56-
verticalAlign="inherit"
57-
letterSpacing="normal"
58-
>
59-
{column}
60-
</Th>
50+
<TableHead key={idx}>{column}</TableHead>
6151
))}
6252

6353
{content && content[0]?.url && (
64-
<Th p={5} fontSize="md" fontWeight="normal" textAlign="end">
65-
<Text as="span" display="inline-block" transform={flipForRtl}>
54+
<TableHead className="text-right font-normal">
55+
<span className="inline-block" style={{ transform: flipForRtl }}>
6656
67-
</Text>
68-
</Th>
57+
</span>
58+
</TableHead>
6959
)}
70-
</Tr>
71-
</Thead>
72-
<Tbody>
60+
</TableRow>
61+
</TableHeader>
62+
<TableBody>
7363
{hasError && (
74-
<Tr p={4}>
75-
<Td colSpan={4}>{t("page-stablecoins-table-error")}</Td>
76-
</Tr>
64+
<TableRow className="p-4">
65+
<TableCell colSpan={4}>
66+
{t("page-stablecoins-table-error")}
67+
</TableCell>
68+
</TableRow>
7769
)}
7870

7971
{content.map(({ name, marketCap, image, type, url }, idx) => (
80-
<Tr
81-
key={idx}
82-
color="text"
83-
_hover={{
84-
textDecoration: "none",
85-
bg: "background.highlight",
86-
}}
87-
_focus={{
88-
bg: "background.base",
89-
color: "body.base",
90-
}}
91-
>
92-
<Td verticalAlign="middle">
72+
<TableRow key={idx}>
73+
<TableCell>
9374
<Flex>
94-
{image && <Image src={image} alt="" me={4} boxSize={6} />}
75+
{image && <img src={image} alt="" className="me-4 h-6 w-6" />}
9576
<>{name}</>
9677
</Flex>
97-
</Td>
98-
<Td verticalAlign="middle">{marketCap}</Td>
99-
<Td verticalAlign="middle">{stablecoinsType[type]}</Td>
78+
</TableCell>
79+
<TableCell>{marketCap}</TableCell>
80+
<TableCell>{stablecoinsType[type]}</TableCell>
10081
{url && (
101-
<Td textAlign="end">
82+
<TableCell className="text-right">
10283
<ButtonLink href={url} size="sm">
10384
{t("page-stablecoins-go-to")} {name}
10485
</ButtonLink>
105-
</Td>
86+
</TableCell>
10687
)}
107-
</Tr>
88+
</TableRow>
10889
))}
109-
</Tbody>
90+
</TableBody>
11091
</Table>
11192
)
11293
}

0 commit comments

Comments
 (0)