@@ -2,78 +2,30 @@ import React, { useState } from "react"
22import reverse from "lodash/reverse"
33import sortBy from "lodash/sortBy"
44import { 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"
145
156import type { CostLeaderboardData } from "@/lib/types"
167
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 "
1910
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"
4912
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"
5615
16+ const RadioCard = ( { value, children, checked, onChange } ) => {
5717 return (
5818 < 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+ ) }
6625 >
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 >
7729 </ Button >
7830 )
7931}
@@ -92,12 +44,6 @@ const TranslationLeaderboard = ({
9244 quarterData,
9345 allTimeData,
9446} : TranslationLeaderboardProps ) => {
95- const tableBoxShadow = useColorModeValue ( "tableBox.light" , "tableBox.dark" )
96- const tableItemBoxShadow = useColorModeValue (
97- "tableItemBox.light" ,
98- "tableItemBox.dark"
99- )
100-
10147 const leaderboardData = {
10248 monthData : sortAndFilterData ( monthData ) ,
10349 quarterData : sortAndFilterData ( quarterData ) ,
@@ -115,75 +61,52 @@ const TranslationLeaderboard = ({
11561 updateFilterAmount ( 50 )
11662 }
11763
118- const { getRadioProps } = useRadioGroup ( {
119- name : "period selection" ,
120- defaultValue : "monthData" ,
121- onChange : updateDateRangeType ,
122- } )
123-
12464 const { t } = useTranslation (
12565 "page-contributing-translation-program-acknowledgements"
12666 )
12767
12868 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+ >
13976 { t (
14077 "page-contributing-translation-program-acknowledgements-translation-leaderboard-month-view"
14178 ) }
14279 </ RadioCard >
14380 < RadioCard
144- key = "quarterData"
145- { ...getRadioProps ( { value : "quarterData" } ) }
81+ value = "quarterData"
82+ checked = { dateRangeType === "quarterData" }
83+ onChange = { updateDateRangeType }
14684 >
14785 { t (
14886 "page-contributing-translation-program-acknowledgements-translation-leaderboard-quarter-view"
14987 ) }
15088 </ RadioCard >
15189 < RadioCard
152- key = "allTimeData"
153- { ...getRadioProps ( { value : "allTimeData" } ) }
90+ value = "allTimeData"
91+ checked = { dateRangeType === "allTimeData" }
92+ onChange = { updateDateRangeType }
15493 >
15594 { t (
15695 "page-contributing-translation-program-acknowledgements-translation-leaderboard-all-time-view"
15796 ) }
15897 </ RadioCard >
15998 </ 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" >
171101 < 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" >
181104 { t (
182105 "page-contributing-translation-program-acknowledgements-translator"
183106 ) }
184107 </ Flex >
185108 </ Flex >
186- < Flex minW = " 20%" flexDirection = " row" alignItems = " start">
109+ < Flex className = "min-w-[ 20%] flex- row items- start">
187110 { t (
188111 "page-contributing-translation-program-acknowledgements-total-words"
189112 ) }
@@ -204,55 +127,35 @@ const TranslationLeaderboard = ({
204127 }
205128 return (
206129 < 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- } }
221130 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"
222132 >
223133 < Flex >
224- { emoji ? (
225- < Box w = { 10 } >
134+ < div className = "flex w-10 items-center" >
135+ { emoji ? (
226136 < 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" >
248151 { username }
249- < Text m = { 0 } display = "block" fontSize = "sm" opacity = "0.6 ">
152+ < span className = "block text-sm opacity-60 " >
250153 { langs [ 0 ] }
251- </ Text >
252- </ Box >
154+ </ span >
155+ </ div >
253156 </ Flex >
254157 </ Flex >
255- < Flex minW = " 20%" flexDirection = " row" alignItems = " start">
158+ < Flex className = "min-w-[ 20%] flex- row items- start">
256159 < Emoji
257160 text = ":writing:"
258161 className = "me-2 hidden text-2xl sm:block"
@@ -262,32 +165,23 @@ const TranslationLeaderboard = ({
262165 </ Flex >
263166 )
264167 } ) }
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" >
282176 { t (
283177 filterAmount === 10
284178 ? "page-contributing-translation-program-acknowledgements-translation-leaderboard-show-more"
285179 : "page-contributing-translation-program-acknowledgements-translation-leaderboard-show-less"
286180 ) }
287- </ Text >
181+ </ span >
288182 </ Button >
289183 </ Flex >
290- </ Box >
184+ </ div >
291185 )
292186}
293187
0 commit comments