Skip to content

Commit 0c8ec97

Browse files
committed
Convert styles to a Button component
1 parent 12f313d commit 0c8ec97

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

src/components/TranslationLeaderboard.tsx

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useState } from "react"
33
import { reverse, sortBy } from "lodash"
44
import {
55
Box,
6+
Button as ChakraButton,
67
Flex,
78
Img,
89
Text,
@@ -21,17 +22,10 @@ export interface IProps {
2122
allTimeData: any
2223
}
2324

24-
const RadioCard = (props) => {
25-
const shadow = useColorModeValue("tableBox.light", "tableBox.dark")
26-
const { getInputProps, getCheckboxProps } = useRadio(props)
27-
28-
const input = getInputProps()
29-
const checkbox = getCheckboxProps()
30-
25+
const Button = (props) => {
3126
return (
32-
<Flex
33-
as="label"
34-
{...checkbox}
27+
<ChakraButton
28+
display="flex"
3529
borderRadius="2rem"
3630
borderWidth="1px"
3731
borderStyle="solid"
@@ -41,6 +35,7 @@ const RadioCard = (props) => {
4135
py={4}
4236
px={6}
4337
m={2}
38+
h="full"
4439
cursor="pointer"
4540
bg="transparent"
4641
w={{ base: "full", lg: "initial" }}
@@ -51,6 +46,22 @@ const RadioCard = (props) => {
5146
color: "primary",
5247
borderColor: "primary",
5348
}}
49+
{...props}
50+
/>
51+
)
52+
}
53+
54+
const RadioCard = (props) => {
55+
const shadow = useColorModeValue("tableBox.light", "tableBox.dark")
56+
const { getInputProps, getCheckboxProps } = useRadio(props)
57+
58+
const input = getInputProps()
59+
const checkbox = getCheckboxProps()
60+
61+
return (
62+
<Button
63+
as="label"
64+
{...checkbox}
5465
_checked={{
5566
borderColor: "primary",
5667
color: "primary",
@@ -67,7 +78,7 @@ const RadioCard = (props) => {
6778
>
6879
{props.children}
6980
</Text>
70-
</Flex>
81+
</Button>
7182
)
7283
}
7384

@@ -262,28 +273,7 @@ const TranslationLeaderboard: React.FC<IProps> = ({
262273
flexDirection={{ base: "column", lg: "inherit" }}
263274
w="full"
264275
>
265-
<Flex
266-
borderRadius="2rem"
267-
borderWidth="1px"
268-
borderStyle="solid"
269-
borderColor="text"
270-
color="text"
271-
alignItems="center"
272-
py={4}
273-
px={6}
274-
m={2}
275-
cursor="pointer"
276-
bg="transparent"
277-
w={{ base: "full", lg: "initial" }}
278-
justifyContent="center"
279-
ml={{ base: "0", lg: "2" }}
280-
mr={{ base: "0", lg: "2" }}
281-
_hover={{
282-
color: "primary",
283-
borderColor: "primary",
284-
}}
285-
onClick={filterAmount === 10 ? showMore : showLess}
286-
>
276+
<Button onClick={filterAmount === 10 ? showMore : showLess}>
287277
<Text
288278
as="span"
289279
fontSize={{ base: "md", md: "lg" }}
@@ -299,7 +289,7 @@ const TranslationLeaderboard: React.FC<IProps> = ({
299289
}
300290
/>
301291
</Text>
302-
</Flex>
292+
</Button>
303293
</Flex>
304294
</Box>
305295
)

0 commit comments

Comments
 (0)