1
+ import { BaseHTMLAttributes } from "react"
1
2
import { useTranslation } from "next-i18next"
2
- import {
3
- Box ,
4
- type BoxProps ,
5
- Center ,
6
- type CenterProps ,
7
- Divider ,
8
- Flex ,
9
- type FlexProps ,
10
- Heading ,
11
- type HeadingProps ,
12
- type TextProps ,
13
- useToken ,
14
- } from "@chakra-ui/react"
15
3
16
4
import type { ChildOnlyProp , TranslationKey } from "@/lib/types"
17
5
18
- import { ButtonLink , type ButtonLinkProps } from "@/components/Buttons"
19
- import Text from "@/components/OldText"
6
+ import { cn } from "@/lib/utils/cn"
7
+
8
+ import { ButtonLink , ButtonLinkProps } from "./ui/buttons/Button"
9
+ import { Center , Flex , Stack } from "./ui/flex"
10
+
11
+ type FlexProps = BaseHTMLAttributes < HTMLDivElement >
20
12
21
13
const CardRow = ( { children } : ChildOnlyProp ) => (
22
- < Flex justifyContent = "space-between" my = "16" mx = "4" flexWrap = "wrap" >
23
- { children }
24
- </ Flex >
14
+ < Flex className = "mx-4 my-16 flex-wrap justify-between" > { children } </ Flex >
25
15
)
26
16
27
17
const SubmitBugBountyButton = ( { children, ...props } : ButtonLinkProps ) => (
28
- < ButtonLink m = "4" href = "https://forms.gle/Gnh4gzGh66Yc3V7G8" { ...props } >
18
+ < ButtonLink
19
+ className = "m-4"
20
+ href = "https://forms.gle/Gnh4gzGh66Yc3V7G8"
21
+ { ...props }
22
+ >
29
23
{ children }
30
24
</ ButtonLink >
31
25
)
32
26
33
27
const Card = ( { children, ...props } : FlexProps ) => {
34
- const tableBoxShadow = useToken ( "colors" , "tableBoxShadow" )
35
-
36
28
return (
37
- < Flex
38
- flexDir = "column"
39
- flex = { { base : "1 1 412px" , xl : "1 1 260px" } }
40
- justifyContent = "space-between"
41
- bg = "background.base"
42
- borderRadius = "2px"
43
- borderRad
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
- } }
29
+ < Stack
30
+ className = { cn (
31
+ "flex-[1_1_412px] gap-0 xl:flex-[1_1_216px]" ,
32
+ "m-4 justify-between bg-background" ,
33
+ "rounded-sm border shadow-table-box" ,
34
+ "hover:scale-[1.02] hover:rounded hover:bg-background-highlight hover:shadow-table-box-hover hover:transition-transform hover:duration-100"
35
+ ) }
55
36
{ ...props }
56
37
>
57
38
{ children }
58
- </ Flex >
39
+ </ Stack >
59
40
)
60
41
}
61
42
62
43
type LabelVariant = "low" | "medium" | "high" | "critical"
63
44
64
- type LabelProps = CenterProps & {
45
+ type LabelProps = FlexProps & {
65
46
variant : LabelVariant
66
47
}
67
48
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
- } ,
49
+ const classNameByVariant = {
50
+ low : "bg-red-100 text-black" ,
51
+ medium : "bg-red-300 text-black" ,
52
+ high : "bg-red-700 text-white" ,
53
+ critical : "bg-red-900 text-white" ,
85
54
}
86
55
87
56
const Label = ( { children, variant = "medium" , ...props } : LabelProps ) => {
88
- const variantStyleProps = stylePropsByVariant [ variant ]
57
+ const variantClassName = classNameByVariant [ variant ]
89
58
90
59
return (
91
60
< Center
92
- borderTopEndRadius = "1px"
93
- borderTopStartRadius = "1px"
94
- borderBottomEndRadius = { 0 }
95
- borderBottomStartRadius = { 0 }
96
- borderBottom = "1px solid"
97
- borderColor = "border"
98
- fontSize = "sm"
99
- px = "0"
100
- py = "1"
101
- textTransform = "uppercase"
102
- { ...variantStyleProps }
61
+ className = { cn (
62
+ "rounded-t-[1px] border-b px-0 py-1 text-sm uppercase" ,
63
+ variantClassName
64
+ ) }
103
65
{ ...props }
104
66
>
105
67
{ children }
106
68
</ Center >
107
69
)
108
70
}
109
71
110
- const H2 = ( { children, ...props } : HeadingProps ) => (
111
- < Heading
112
- fontSize = "2xl"
113
- fontStyle = "normal"
114
- fontWeight = "bold"
115
- lineHeight = "22px"
116
- letterSpacing = "normal"
117
- p = "4"
118
- textAlign = "start"
119
- mb = "-2"
120
- mt = "2"
72
+ const H2 = ( { children, ...props } ) => (
73
+ < h2
74
+ className = { cn ( "-mb-2 mt-2 p-4" , "text-start text-2xl font-bold leading-6" ) }
121
75
{ ...props }
122
76
>
123
77
{ children }
124
- </ Heading >
78
+ </ h2 >
125
79
)
126
80
127
- const Description = ( { children, ...props } : TextProps ) => (
128
- < Text as = "p" fontSize = "xl" px = "4" py = "0" opacity = "0.6 " { ...props } >
81
+ const Description = ( { children, ...props } ) => (
82
+ < p className = "mb-6 px-4 py-0 text-xl opacity-60 " { ...props } >
129
83
{ children }
130
- </ Text >
84
+ </ p >
131
85
)
132
86
133
- const SubHeader = ( { children, ...props } : TextProps ) => (
134
- < Text
135
- as = "p"
136
- textTransform = "uppercase"
137
- fontSize = "sm"
138
- ms = "4"
139
- mt = "4"
140
- mb = "2"
141
- opacity = "0.6"
142
- { ...props }
143
- >
87
+ const SubHeader = ( { children, ...props } ) => (
88
+ < p className = "mb-2 ms-4 mt-4 text-sm uppercase opacity-60" { ...props } >
144
89
{ children }
145
- </ Text >
90
+ </ p >
146
91
)
147
92
148
- const TextBox = ( { children, ...props } : BoxProps ) => (
149
- < Box m = "4" mt = "2" { ...props } >
93
+ const TextBox = ( {
94
+ children,
95
+ ...props
96
+ } : BaseHTMLAttributes < HTMLDivElement > ) => (
97
+ < div className = "m-4 mt-2" { ...props } >
150
98
{ children }
151
- </ Box >
99
+ </ div >
152
100
)
153
101
154
102
export interface BugBountyCardInfo {
@@ -246,7 +194,7 @@ const BugBountyCards = () => {
246
194
< H2 > { t ( card . h2TranslationId ) } </ H2 >
247
195
< Description > { t ( card . descriptionTranslationId ) } </ Description >
248
196
< SubHeader > { t ( card . subDescriptionTranslationId ) } </ SubHeader >
249
- < Divider opacity = "1" />
197
+
250
198
< SubHeader > { t ( card . subHeader1TranslationId ) } </ SubHeader >
251
199
< TextBox >
252
200
< ul >
@@ -258,7 +206,7 @@ const BugBountyCards = () => {
258
206
) ) }
259
207
</ ul >
260
208
</ TextBox >
261
- < Divider opacity = "1" />
209
+
262
210
< SubHeader > { t ( card . subHeader2TranslationId ) } </ SubHeader >
263
211
< TextBox > { t ( card . textTranslationId ) } </ TextBox >
264
212
< SubmitBugBountyButton >
0 commit comments