@@ -2,78 +2,30 @@ import React, { useState } from "react"
2
2
import reverse from "lodash/reverse"
3
3
import sortBy from "lodash/sortBy"
4
4
import { useTranslation } from "next-i18next"
5
- import {
6
- Box ,
7
- Button as ChakraButton ,
8
- Flex ,
9
- Img ,
10
- useColorModeValue ,
11
- useRadio ,
12
- useRadioGroup ,
13
- } from "@chakra-ui/react"
14
5
15
6
import type { CostLeaderboardData } from "@/lib/types"
16
7
17
- import Emoji from "./Emoji "
18
- import Text from "./OldText "
8
+ import { Button } from "@/components/ui/buttons/Button "
9
+ import { Flex } from "@/components/ui/flex "
19
10
20
- const Button = ( props ) => {
21
- return (
22
- < ChakraButton
23
- display = "flex"
24
- borderRadius = "2rem"
25
- borderWidth = "1px"
26
- borderStyle = "solid"
27
- borderColor = "text"
28
- color = "text"
29
- alignItems = "center"
30
- py = { 4 }
31
- px = { 6 }
32
- m = { 2 }
33
- h = "full"
34
- cursor = "pointer"
35
- bg = "transparent"
36
- w = { { base : "full" , lg : "initial" } }
37
- justifyContent = "center"
38
- mx = { { base : "0" , lg : "2" } }
39
- _hover = { {
40
- color : "primary.base" ,
41
- borderColor : "primary.base" ,
42
- } }
43
- _focus = { { } }
44
- _active = { { } }
45
- { ...props }
46
- />
47
- )
48
- }
11
+ import { cn } from "@/lib/utils/cn"
49
12
50
- const RadioCard = ( props ) => {
51
- const shadow = useColorModeValue ( "tableBox.light" , "tableBox.dark" )
52
- const { getInputProps, getCheckboxProps } = useRadio ( props )
53
-
54
- const input = getInputProps ( )
55
- const checkbox = getCheckboxProps ( )
13
+ import Emoji from "./Emoji"
14
+ import { TwImage } from "./Image"
56
15
16
+ const RadioCard = ( { value, children, checked, onChange } ) => {
57
17
return (
58
18
< Button
59
- as = "label"
60
- { ...checkbox }
61
- _checked = { {
62
- borderColor : "primary.base" ,
63
- color : "primary.base" ,
64
- boxShadow : shadow ,
65
- } }
19
+ variant = "ghost"
20
+ onClick = { ( ) => onChange ( value ) }
21
+ className = { cn (
22
+ "m-2 mx-0 flex h-full w-full items-center justify-center rounded-full px-6 py-4 lg:mx-2 lg:w-auto" ,
23
+ checked && "border-primary text-primary shadow-md"
24
+ ) }
66
25
>
67
- < input { ...input } />
68
- < Text
69
- as = "span"
70
- fontSize = { { base : "md" , md : "lg" } }
71
- lineHeight = "100%"
72
- textAlign = "center"
73
- fontWeight = { { base : "semibold" , md : "normal" } }
74
- >
75
- { props . children }
76
- </ Text >
26
+ < span className = "text-center text-md font-semibold leading-none md:text-lg md:font-normal" >
27
+ { children }
28
+ </ span >
77
29
</ Button >
78
30
)
79
31
}
@@ -92,12 +44,6 @@ const TranslationLeaderboard = ({
92
44
quarterData,
93
45
allTimeData,
94
46
} : TranslationLeaderboardProps ) => {
95
- const tableBoxShadow = useColorModeValue ( "tableBox.light" , "tableBox.dark" )
96
- const tableItemBoxShadow = useColorModeValue (
97
- "tableItemBox.light" ,
98
- "tableItemBox.dark"
99
- )
100
-
101
47
const leaderboardData = {
102
48
monthData : sortAndFilterData ( monthData ) ,
103
49
quarterData : sortAndFilterData ( quarterData ) ,
@@ -115,75 +61,52 @@ const TranslationLeaderboard = ({
115
61
updateFilterAmount ( 50 )
116
62
}
117
63
118
- const { getRadioProps } = useRadioGroup ( {
119
- name : "period selection" ,
120
- defaultValue : "monthData" ,
121
- onChange : updateDateRangeType ,
122
- } )
123
-
124
64
const { t } = useTranslation (
125
65
"page-contributing-translation-program-acknowledgements"
126
66
)
127
67
128
68
return (
129
- < Box >
130
- < Flex
131
- justifyContent = "center"
132
- py = { 0 }
133
- px = { 8 }
134
- mb = { 8 }
135
- flexDirection = { { base : "column" , lg : "inherit" } }
136
- w = "full"
137
- >
138
- < RadioCard key = "monthData" { ...getRadioProps ( { value : "monthData" } ) } >
69
+ < div >
70
+ < Flex className = "mb-8 w-full flex-col justify-center px-8 py-0 lg:flex-row" >
71
+ < RadioCard
72
+ value = "monthData"
73
+ checked = { dateRangeType === "monthData" }
74
+ onChange = { updateDateRangeType }
75
+ >
139
76
{ t (
140
77
"page-contributing-translation-program-acknowledgements-translation-leaderboard-month-view"
141
78
) }
142
79
</ RadioCard >
143
80
< RadioCard
144
- key = "quarterData"
145
- { ...getRadioProps ( { value : "quarterData" } ) }
81
+ value = "quarterData"
82
+ checked = { dateRangeType === "quarterData" }
83
+ onChange = { updateDateRangeType }
146
84
>
147
85
{ t (
148
86
"page-contributing-translation-program-acknowledgements-translation-leaderboard-quarter-view"
149
87
) }
150
88
</ RadioCard >
151
89
< RadioCard
152
- key = "allTimeData"
153
- { ...getRadioProps ( { value : "allTimeData" } ) }
90
+ value = "allTimeData"
91
+ checked = { dateRangeType === "allTimeData" }
92
+ onChange = { updateDateRangeType }
154
93
>
155
94
{ t (
156
95
"page-contributing-translation-program-acknowledgements-translation-leaderboard-all-time-view"
157
96
) }
158
97
</ RadioCard >
159
98
</ Flex >
160
- < Box bg = "background.base" boxShadow = { tableBoxShadow } w = "full" mb = { 8 } >
161
- < Flex
162
- bg = "grayBackground"
163
- textDecoration = "none"
164
- justifyContent = "space-between"
165
- alignItems = "center"
166
- color = "text"
167
- mb = "1px"
168
- p = { 4 }
169
- w = "full"
170
- >
99
+ < div className = "mb-8 w-full bg-background-highlight shadow-md" >
100
+ < Flex className = "bg-muted text-foreground mb-[1px] w-full items-center justify-between p-4" >
171
101
< Flex >
172
- < Box w = { 10 } opacity = "0.4" >
173
- #
174
- </ Box >
175
- < Flex
176
- flexDirection = "row"
177
- alignItems = "center"
178
- me = { 8 }
179
- overflowWrap = "anywhere"
180
- >
102
+ < div className = "w-10 opacity-40" > #</ div >
103
+ < Flex className = "me-8 flex-row items-center break-words" >
181
104
{ t (
182
105
"page-contributing-translation-program-acknowledgements-translator"
183
106
) }
184
107
</ Flex >
185
108
</ Flex >
186
- < Flex minW = " 20%" flexDirection = " row" alignItems = " start">
109
+ < Flex className = "min-w-[ 20%] flex- row items- start">
187
110
{ t (
188
111
"page-contributing-translation-program-acknowledgements-total-words"
189
112
) }
@@ -204,55 +127,35 @@ const TranslationLeaderboard = ({
204
127
}
205
128
return (
206
129
< Flex
207
- textDecoration = "none"
208
- justifyContent = "space-between"
209
- alignItems = "center"
210
- color = "text"
211
- boxShadow = { tableItemBoxShadow }
212
- mb = "1px"
213
- py = { 2 }
214
- px = { 4 }
215
- w = "full"
216
- _hover = { {
217
- borderRadius : "base" ,
218
- boxShadow : "tableItemBoxHover" ,
219
- bg : "tableBackgroundHover" ,
220
- } }
221
130
key = { idx }
131
+ className = "text-foreground hover:rounded-base hover:bg-accent/50 mb-[1px] w-full items-center justify-between px-4 py-2 shadow-sm hover:shadow-md"
222
132
>
223
133
< Flex >
224
- { emoji ? (
225
- < Box w = { 10 } >
134
+ < div className = "flex w-10 items-center" >
135
+ { emoji ? (
226
136
< Emoji className = "me-4 text-[2rem]" text = { emoji } />
227
- </ Box >
228
- ) : (
229
- < Box w = { 10 } opacity = "0.4" >
230
- { idx + 1 }
231
- </ Box >
232
- ) }
233
- < Flex
234
- flexDirection = "row"
235
- alignItems = "center"
236
- me = { 8 }
237
- overflowWrap = "anywhere"
238
- >
239
- < Img
240
- me = { 4 }
241
- h = { { base : "30px" , sm : 10 } }
242
- w = { { base : "30px" , sm : 10 } }
243
- borderRadius = "50%"
244
- display = { { base : "none" , s : "block" } }
245
- src = { avatarUrl }
246
- />
247
- < Box maxW = { { base : "100px" , sm : "none" } } >
137
+ ) : (
138
+ < span className = "opacity-40" > { idx + 1 } </ span >
139
+ ) }
140
+ </ div >
141
+ < Flex className = "me-8 flex-row items-center break-words" >
142
+ < div className = "relative me-4 hidden h-[30px] w-[30px] sm:block sm:h-10 sm:w-10" >
143
+ < TwImage
144
+ fill
145
+ className = "rounded-full object-cover"
146
+ src = { avatarUrl }
147
+ alt = { username }
148
+ />
149
+ </ div >
150
+ < div className = "max-w-[100px] sm:max-w-none" >
248
151
{ username }
249
- < Text m = { 0 } display = "block" fontSize = "sm" opacity = "0.6 ">
152
+ < span className = "block text-sm opacity-60 " >
250
153
{ langs [ 0 ] }
251
- </ Text >
252
- </ Box >
154
+ </ span >
155
+ </ div >
253
156
</ Flex >
254
157
</ Flex >
255
- < Flex minW = " 20%" flexDirection = " row" alignItems = " start">
158
+ < Flex className = "min-w-[ 20%] flex- row items- start">
256
159
< Emoji
257
160
text = ":writing:"
258
161
className = "me-2 hidden text-2xl sm:block"
@@ -262,32 +165,23 @@ const TranslationLeaderboard = ({
262
165
</ Flex >
263
166
)
264
167
} ) }
265
- </ Box >
266
- < Flex
267
- justifyContent = "center"
268
- py = { 0 }
269
- px = { 8 }
270
- mb = { 8 }
271
- flexDirection = { { base : "column" , lg : "inherit" } }
272
- w = "full"
273
- >
274
- < Button onClick = { filterAmount === 10 ? showMore : showLess } >
275
- < Text
276
- as = "span"
277
- fontSize = { { base : "md" , md : "lg" } }
278
- lineHeight = "100%"
279
- textAlign = "center"
280
- fontWeight = { { base : "semibold" , md : "normal" } }
281
- >
168
+ </ div >
169
+ < Flex className = "mb-8 w-full flex-col justify-center px-8 py-0 lg:flex-row" >
170
+ < Button
171
+ variant = "ghost"
172
+ onClick = { filterAmount === 10 ? showMore : showLess }
173
+ className = "m-2 mx-0 flex h-full w-full items-center justify-center rounded-full px-6 py-4 lg:mx-2 lg:w-auto"
174
+ >
175
+ < span className = "text-center text-md font-semibold leading-none md:text-lg md:font-normal" >
282
176
{ t (
283
177
filterAmount === 10
284
178
? "page-contributing-translation-program-acknowledgements-translation-leaderboard-show-more"
285
179
: "page-contributing-translation-program-acknowledgements-translation-leaderboard-show-less"
286
180
) }
287
- </ Text >
181
+ </ span >
288
182
</ Button >
289
183
</ Flex >
290
- </ Box >
184
+ </ div >
291
185
)
292
186
}
293
187
0 commit comments