1
1
import React from "react"
2
- import styled from "@emotion/styled"
2
+ import {
3
+ Center ,
4
+ CenterProps ,
5
+ Flex ,
6
+ FlexProps ,
7
+ Heading ,
8
+ HeadingProps ,
9
+ Text ,
10
+ TextProps ,
11
+ Divider ,
12
+ Box ,
13
+ BoxProps ,
14
+ useToken ,
15
+ } from "@chakra-ui/react"
16
+
3
17
import { TranslationKey } from "../utils/translations"
4
18
import ButtonLink from "./ButtonLink"
5
19
6
20
import Translation from "./Translation"
7
21
8
- const CardRow = styled . div `
9
- display: flex;
10
- justify-content: space-between;
11
- margin: 4rem 1rem;
12
- flex-wrap: wrap;
13
- `
14
-
15
- const StyledButton = styled ( ButtonLink ) `
16
- margin: 1rem;
17
- `
18
-
19
- const Card = styled . div `
20
- flex: 1 1 260px;
21
- @media (max-width: 1228px) {
22
- flex: 1 1 360px;
23
- }
24
- display: flex;
25
- flex-direction: column;
26
- background: ${ ( props ) => props . theme . colors . Background } ;
27
- border-radius: 2px;
28
- box-shadow: ${ ( props ) => props . theme . colors . tableBoxShadow } ;
29
- border: 1px solid ${ ( props ) => props . theme . colors . border } ;
30
- margin: 1rem;
31
- justify-content: space-between;
32
- &:hover {
33
- border-radius: 4px;
34
- box-shadow: 0px 8px 17px rgba(0, 0, 0, 0.15);
35
- background: ${ ( props ) => props . theme . colors . tableBackgroundHover } ;
36
- transition: transform 0.1s;
37
- transform: scale(1.02);
38
- }
39
- `
40
-
41
- const Label = styled . div `
42
- display: flex;
43
- justify-content: center;
44
- font-size: 0.875rem;
45
- text-transform: uppercase;
46
- border-top-left-radius: 1px;
47
- border-top-right-radius: 1px;
48
- border-bottom-right-radius: 0;
49
- border-bottom-left-radius: 0;
50
- border-bottom: 1px solid ${ ( props ) => props . theme . colors . border } ;
51
- padding: 0.25rem 0rem;
52
- `
53
-
54
- const LowLabel = styled ( Label ) `
55
- background: ${ ( props ) => props . theme . colors . lowBug } ;
56
- color: ${ ( props ) => props . theme . colors . black300 } ;
57
- `
58
-
59
- const MediumLabel = styled ( Label ) `
60
- background: ${ ( props ) => props . theme . colors . mediumBug } ;
61
- color: ${ ( props ) => props . theme . colors . black300 } ;
62
- `
63
-
64
- const HighLabel = styled ( Label ) `
65
- background: ${ ( props ) => props . theme . colors . fail400 } ;
66
- color: ${ ( props ) => props . theme . colors . white } ;
67
- `
68
-
69
- const CriticalLabel = styled ( Label ) `
70
- background: ${ ( props ) => props . theme . colors . fail600 } ;
71
- color: ${ ( props ) => props . theme . colors . white } ;
72
- `
73
-
74
- const H2 = styled . h2 `
75
- font-size: 1.5rem;
76
- font-style: normal;
77
- font-weight: 700;
78
- line-height: 22px;
79
- letter-spacing: 0px;
80
- padding: 1rem;
81
- text-align: left;
82
- margin-bottom: -0.5rem;
83
- margin-top: 0.5rem;
84
- `
85
-
86
- const Description = styled . p `
87
- font-size: 1.25rem;
88
- padding: 1rem;
89
- padding-top: 0rem;
90
- padding-bottom: 0rem;
91
- opacity: 0.6;
92
- `
93
-
94
- const Divider = styled . div `
95
- border-bottom: 1px solid ${ ( props ) => props . theme . colors . border } ;
96
- `
97
-
98
- const SubHeader = styled . p `
99
- text-transform: uppercase;
100
- font-size: 0.875rem;
101
- margin-left: 1rem;
102
- margin-top: 1rem;
103
- margin-bottom: 0.5rem;
104
- opacity: 0.6;
105
- `
106
-
107
- const Text = styled . div `
108
- margin: 1rem;
109
- margin-top: 0.5rem;
110
- `
22
+ const CardRow = ( { children } ) => (
23
+ < Flex justifyContent = "space-between" my = { 16 } mx = { 4 } flexWrap = "wrap" >
24
+ { children }
25
+ </ Flex >
26
+ )
27
+
28
+ const SubmitBugBountyButton = ( { children, ...props } ) => (
29
+ < ButtonLink m = { 4 } to = "https://forms.gle/Gnh4gzGh66Yc3V7G8" { ...props } >
30
+ { children }
31
+ </ ButtonLink >
32
+ )
33
+
34
+ const Card = ( { children, ...props } : FlexProps ) => {
35
+ const tableBoxShadow = useToken ( "colors" , "tableBoxShadow" )
36
+
37
+ return (
38
+ < Flex
39
+ flexDir = "column"
40
+ flex = { { base : "1 1 412px" , xl : "1 1 260px" } }
41
+ justifyContent = "space-between"
42
+ bg = "background"
43
+ borderRadius = "2px"
44
+ boxShadow = { tableBoxShadow }
45
+ border = "1px solid"
46
+ borderColor = "border"
47
+ m = { 4 }
48
+ _hover = { {
49
+ borderRadius : "base" ,
50
+ boxShadow : "tableBoxHover" ,
51
+ background : "tableBackgroundHover" ,
52
+ transition : "transform 0.1s" ,
53
+ transform : "scale(1.02)" ,
54
+ } }
55
+ { ...props }
56
+ >
57
+ { children }
58
+ </ Flex >
59
+ )
60
+ }
61
+
62
+ type LabelVariant = "low" | "medium" | "high" | "critical"
63
+
64
+ type LabelProps = CenterProps & {
65
+ variant : LabelVariant
66
+ }
67
+
68
+ const stylePropsByVariant = {
69
+ low : {
70
+ bg : "lowBug" ,
71
+ color : "black300" ,
72
+ } ,
73
+ medium : {
74
+ bg : "mediumBug" ,
75
+ color : "black300" ,
76
+ } ,
77
+ high : {
78
+ bg : "fail400" ,
79
+ color : "white" ,
80
+ } ,
81
+ critical : {
82
+ bg : "fail600" ,
83
+ color : "white" ,
84
+ } ,
85
+ }
86
+
87
+ const Label = ( { children, variant = "medium" , ...props } : LabelProps ) => {
88
+ const variantStyleProps = stylePropsByVariant [ variant ]
89
+
90
+ return (
91
+ < Center
92
+ borderTopRightRadius = "1px"
93
+ borderTopLeftRadius = "1px"
94
+ borderBottomRightRadius = { 0 }
95
+ borderBottomLeftRadius = { 0 }
96
+ borderBottom = "1px solid"
97
+ borderColor = "border"
98
+ fontSize = "sm"
99
+ px = { 0 }
100
+ py = { 1 }
101
+ textTransform = "uppercase"
102
+ { ...variantStyleProps }
103
+ { ...props }
104
+ >
105
+ { children }
106
+ </ Center >
107
+ )
108
+ }
109
+
110
+ const H2 = ( { children, ...props } : HeadingProps ) => {
111
+ return (
112
+ < Heading
113
+ fontSize = "2xl"
114
+ fontStyle = "normal"
115
+ fontWeight = "bold"
116
+ lineHeight = "22px"
117
+ letterSpacing = { 0 }
118
+ p = { 4 }
119
+ textAlign = "left"
120
+ mb = { - 2 }
121
+ mt = { 2 }
122
+ { ...props }
123
+ >
124
+ { children }
125
+ </ Heading >
126
+ )
127
+ }
128
+
129
+ const Description = ( { children, ...props } : TextProps ) => {
130
+ return (
131
+ < Text as = "p" fontSize = "xl" px = { 4 } py = { 0 } opacity = "0.6" { ...props } >
132
+ { children }
133
+ </ Text >
134
+ )
135
+ }
136
+
137
+ const SubHeader = ( { children, ...props } : TextProps ) => {
138
+ return (
139
+ < Text
140
+ as = "p"
141
+ textTransform = "uppercase"
142
+ fontSize = "sm"
143
+ ml = { 4 }
144
+ mt = { 4 }
145
+ mb = { 2 }
146
+ opacity = "0.6"
147
+ { ...props }
148
+ >
149
+ { children }
150
+ </ Text >
151
+ )
152
+ }
153
+
154
+ const TextBox = ( { children, ...props } : BoxProps ) => {
155
+ return (
156
+ < Box m = { 4 } mt = { 2 } { ...props } >
157
+ { children }
158
+ </ Box >
159
+ )
160
+ }
111
161
112
162
export interface BugBountyCardInfo {
113
163
lowLabelTranslationId ?: TranslationKey
@@ -188,24 +238,24 @@ const BugBountyCards: React.FC<IProps> = () => (
188
238
{ bugBountyCardsInfo . map ( ( card , idx ) => (
189
239
< Card key = { `bug-bounty-card-${ idx } ` } >
190
240
{ card . lowLabelTranslationId && (
191
- < LowLabel >
241
+ < Label variant = "low" >
192
242
< Translation id = { card . lowLabelTranslationId } />
193
- </ LowLabel >
243
+ </ Label >
194
244
) }
195
245
{ card . mediumLabelTranslationId && (
196
- < MediumLabel >
246
+ < Label variant = "medium" >
197
247
< Translation id = { card . mediumLabelTranslationId } />
198
- </ MediumLabel >
248
+ </ Label >
199
249
) }
200
250
{ card . highLabelTranslationId && (
201
- < HighLabel >
251
+ < Label variant = "high" >
202
252
< Translation id = { card . highLabelTranslationId } />
203
- </ HighLabel >
253
+ </ Label >
204
254
) }
205
255
{ card . criticalLabelTranslationId && (
206
- < CriticalLabel >
256
+ < Label variant = "critical" >
207
257
< Translation id = { card . criticalLabelTranslationId } />
208
- </ CriticalLabel >
258
+ </ Label >
209
259
) }
210
260
< H2 >
211
261
< Translation id = { card . h2TranslationId } />
@@ -216,29 +266,29 @@ const BugBountyCards: React.FC<IProps> = () => (
216
266
< SubHeader >
217
267
< Translation id = { card . subDescriptionTranslationId } />
218
268
</ SubHeader >
219
- < Divider />
269
+ < Divider opacity = "1" />
220
270
< SubHeader >
221
271
< Translation id = { card . subHeader1TranslationId } />
222
272
</ SubHeader >
223
- < Text >
273
+ < TextBox >
224
274
< ul >
225
275
{ card . severityList . map ( ( listItemId ) => (
226
276
< li key = { `${ listItemId } ` } >
227
277
< Translation id = { listItemId } />
228
278
</ li >
229
279
) ) }
230
280
</ ul >
231
- </ Text >
232
- < Divider />
281
+ </ TextBox >
282
+ < Divider opacity = "1" />
233
283
< SubHeader >
234
284
< Translation id = { card . subHeader2TranslationId } />
235
285
</ SubHeader >
236
- < Text >
286
+ < TextBox >
237
287
< Translation id = { card . textTranslationId } />
238
- </ Text >
239
- < StyledButton to = "https://forms.gle/Gnh4gzGh66Yc3V7G8" >
288
+ </ TextBox >
289
+ < SubmitBugBountyButton >
240
290
< Translation id = { card . styledButtonTranslationId } />
241
- </ StyledButton >
291
+ </ SubmitBugBountyButton >
242
292
</ Card >
243
293
) ) }
244
294
</ CardRow >
0 commit comments