@@ -6,14 +6,72 @@ import { reverse, sortBy } from "lodash"
6
6
import Emoji from "./Emoji"
7
7
import { Option , OptionText } from "./SharedStyledComponents"
8
8
import Translation from "./Translation"
9
- import { Box , Flex , Img , Text , useColorModeValue } from "@chakra-ui/react"
9
+ import {
10
+ Box ,
11
+ Flex ,
12
+ Img ,
13
+ Text ,
14
+ useColorModeValue ,
15
+ useRadio ,
16
+ useRadioGroup ,
17
+ } from "@chakra-ui/react"
10
18
11
19
export interface IProps {
12
20
monthData : any
13
21
quarterData : any
14
22
allTimeData : any
15
23
}
16
24
25
+ const RadioCard = ( props ) => {
26
+ const shadow = useColorModeValue ( "tableBox.light" , "tableBox.dark" )
27
+ const { getInputProps, getCheckboxProps } = useRadio ( props )
28
+
29
+ const input = getInputProps ( )
30
+ const checkbox = getCheckboxProps ( )
31
+
32
+ return (
33
+ < Flex
34
+ as = "label"
35
+ { ...checkbox }
36
+ borderRadius = "2rem"
37
+ borderWidth = "1px"
38
+ borderStyle = "solid"
39
+ borderColor = "text"
40
+ color = "text"
41
+ alignItems = "center"
42
+ py = { 4 }
43
+ px = { 6 }
44
+ m = { 2 }
45
+ cursor = "pointer"
46
+ bg = "transparent"
47
+ w = { { base : "full" , lg : "initial" } }
48
+ justifyContent = "center"
49
+ ml = { { base : "0" , lg : "2" } }
50
+ mr = { { base : "0" , lg : "2" } }
51
+ _hover = { {
52
+ color : "primary" ,
53
+ borderColor : "primary" ,
54
+ } }
55
+ _checked = { {
56
+ borderColor : "primary" ,
57
+ color : "primary" ,
58
+ boxShadow : shadow ,
59
+ } }
60
+ >
61
+ < input { ...input } />
62
+ < Text
63
+ as = "span"
64
+ fontSize = { { base : "md" , md : "lg" } }
65
+ lineHeight = "100%"
66
+ textAlign = "center"
67
+ fontWeight = { { base : "semibold" , md : "normal" } }
68
+ >
69
+ { props . children }
70
+ </ Text >
71
+ </ Flex >
72
+ )
73
+ }
74
+
17
75
const TranslationLeaderboard : React . FC < IProps > = ( {
18
76
monthData,
19
77
quarterData,
@@ -44,6 +102,13 @@ const TranslationLeaderboard: React.FC<IProps> = ({
44
102
updateFilterAmount ( 50 )
45
103
}
46
104
105
+ const { getRootProps, getRadioProps } = useRadioGroup ( {
106
+ name : "framework" ,
107
+ defaultValue : "monthData" ,
108
+ onChange : updateDateRangeType ,
109
+ } )
110
+ const group = getRootProps ( )
111
+
47
112
return (
48
113
< Box >
49
114
< Flex
@@ -54,30 +119,21 @@ const TranslationLeaderboard: React.FC<IProps> = ({
54
119
flexDirection = { { base : "column" , lg : "inherit" } }
55
120
w = "full"
56
121
>
57
- < Option
58
- onClick = { ( ) => updateDateRangeType ( "monthData" ) }
59
- isActive = { dateRangeType === "monthData" }
60
- >
61
- < OptionText fontSize = { "18px" } >
62
- < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-month-view" />
63
- </ OptionText >
64
- </ Option >
65
- < Option
66
- onClick = { ( ) => updateDateRangeType ( "quarterData" ) }
67
- isActive = { dateRangeType === "quarterData" }
122
+ < RadioCard key = { "monthData" } { ...getRadioProps ( { value : "monthData" } ) } >
123
+ < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-month-view" />
124
+ </ RadioCard >
125
+ < RadioCard
126
+ key = { "quarterData" }
127
+ { ...getRadioProps ( { value : "quarterData" } ) }
68
128
>
69
- < OptionText fontSize = { "18px" } >
70
- < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-quarter-view" />
71
- </ OptionText >
72
- </ Option >
73
- < Option
74
- onClick = { ( ) => updateDateRangeType ( "allTimeData" ) }
75
- isActive = { dateRangeType === "allTimeData" }
129
+ < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-quarter-view" />
130
+ </ RadioCard >
131
+ < RadioCard
132
+ key = { "allTimeData" }
133
+ { ...getRadioProps ( { value : "allTimeData" } ) }
76
134
>
77
- < OptionText fontSize = { "18px" } >
78
- < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-all-time-view" />
79
- </ OptionText >
80
- </ Option >
135
+ < Translation id = "page-contributing-translation-program-acknowledgements-translation-leaderboard-all-time-view" />
136
+ </ RadioCard >
81
137
</ Flex >
82
138
< Box bg = "background" boxShadow = { tableBoxShadow } w = "full" mb = { 8 } >
83
139
< Flex
0 commit comments