1
- import * as React from "react"
1
+ import { useTranslation } from "next-i18next"
2
+ import type { ComponentType , ReactNode , SVGProps } from "react"
2
3
import {
3
4
Badge ,
4
5
Box ,
@@ -7,52 +8,55 @@ import {
7
8
Flex ,
8
9
Heading ,
9
10
HStack ,
10
- Icon as ChakraIcon ,
11
+ Icon ,
11
12
List ,
12
13
ListIcon ,
13
14
ListItem ,
14
15
} from "@chakra-ui/react"
15
16
16
- import { ButtonLink } from "../.. /Buttons"
17
+ import { ButtonLink } from "@/components /Buttons"
17
18
import {
18
19
CautionProductGlyphIcon ,
19
20
GreenCheckProductGlyphIcon ,
20
21
UnknownProductGlyphIcon ,
21
22
WarningProductGlyphIcon ,
22
- } from "../../icons/staking"
23
- import Translation from "../../Translation"
23
+ } from "@/components/icons/staking"
24
24
25
25
import { FlagType , Product } from "./types"
26
26
27
- const getIconFromName = ( imageName : string ) : typeof ChakraIcon | undefined => {
28
- const { [ imageName + "GlyphIcon" ] : Icon } = require ( "../icons/staking" )
27
+ const getIconFromName = (
28
+ imageName : string
29
+ ) : ComponentType < SVGProps < SVGElement > > => {
30
+ const {
31
+ [ imageName + "GlyphIcon" ] : Icon ,
32
+ } = require ( "@/components/icons/staking" )
29
33
return Icon
30
34
}
31
35
32
- export const Status = ( { status } : { status : FlagType } ) => {
36
+ const Status = ( { status } : { status : FlagType | undefined } ) => {
33
37
if ( ! status ) return null
34
38
35
- const getStatusIcon = ( ) => {
36
- switch ( status ) {
37
- case "green-check" :
38
- return GreenCheckProductGlyphIcon
39
- case "caution" :
40
- return CautionProductGlyphIcon
41
- case "warning" :
42
- case "false" :
43
- return WarningProductGlyphIcon
44
- default :
45
- return UnknownProductGlyphIcon
46
- }
39
+ const styles = { fontSize : "2xl" , m : 0 }
40
+ switch ( status ) {
41
+ case "green-check" :
42
+ return < ListIcon as = { GreenCheckProductGlyphIcon } { ...styles } />
43
+ case "caution" :
44
+ return < ListIcon as = { CautionProductGlyphIcon } { ...styles } />
45
+ case "warning" :
46
+ case "false" :
47
+ return < ListIcon as = { WarningProductGlyphIcon } { ...styles } />
48
+ default :
49
+ return < ListIcon as = { UnknownProductGlyphIcon } { ...styles } />
47
50
}
48
-
49
- return < ListIcon as = { getStatusIcon ( ) } fontSize = "2xl" m = { 0 } />
50
51
}
51
52
52
- const StakingBadge : React . FC < {
53
+ const StakingBadge = ( {
54
+ type,
55
+ children,
56
+ } : {
53
57
type : "ui" | "platform"
54
- children : React . ReactNode
55
- } > = ( { type , children } ) => {
58
+ children : ReactNode
59
+ } ) => {
56
60
const uiTypeColor = type === "ui" && "stakingPillUI"
57
61
const platformTypeColor = type === "platform" && "stakingPillPlatform"
58
62
@@ -67,11 +71,11 @@ const StakingBadge: React.FC<{
67
71
)
68
72
}
69
73
70
- interface ICardProps {
74
+ type StakingProductCardProps = {
71
75
product : Product
72
76
}
73
77
74
- export const StakingProductCard : React . FC < ICardProps > = ( {
78
+ export const StakingProductCard = ( {
75
79
product : {
76
80
name,
77
81
imageName,
@@ -95,72 +99,69 @@ export const StakingProductCard: React.FC<ICardProps> = ({
95
99
economical,
96
100
matomo,
97
101
} ,
98
- } ) => {
102
+ } : StakingProductCardProps ) => {
99
103
const PADDED_DIV_STYLE : BoxProps = {
100
104
px : 8 ,
101
105
py : 6 ,
102
106
}
103
107
108
+ const { t } = useTranslation ( "page-staking" )
104
109
const Svg = getIconFromName ( imageName )
105
- type DataType = { label : JSX . Element ; status ?: FlagType }
110
+ type DataType = { label : string ; status ?: FlagType }
106
111
const data : DataType [ ] = [
107
112
{
108
- label : < Translation id = "page-staking-considerations-solo-1-title" /> ,
113
+ label : t ( "page-staking-considerations-solo-1-title" ) ,
109
114
status : openSource ,
110
115
} ,
111
116
{
112
- label : < Translation id = "page-staking-considerations-solo-2-title" /> ,
117
+ label : t ( "page-staking-considerations-solo-2-title" ) ,
113
118
status : audited ,
114
119
} ,
115
120
{
116
- label : < Translation id = "page-staking-considerations-solo-3-title" /> ,
121
+ label : t ( "page-staking-considerations-solo-3-title" ) ,
117
122
status : bugBounty ,
118
123
} ,
119
124
{
120
- label : < Translation id = "page-staking-considerations-solo-4-title" /> ,
125
+ label : t ( "page-staking-considerations-solo-4-title" ) ,
121
126
status : battleTested ,
122
127
} ,
123
128
{
124
- label : < Translation id = "page-staking-considerations-solo-5-title" /> ,
129
+ label : t ( "page-staking-considerations-solo-5-title" ) ,
125
130
status : trustless ,
126
131
} ,
127
132
{
128
- label : < Translation id = "page-staking-considerations-solo-6-title" /> ,
133
+ label : t ( "page-staking-considerations-solo-6-title" ) ,
129
134
status : permissionless ,
130
135
} ,
131
136
{
132
- label : < Translation id = "page-staking-considerations-pools-6-title" /> ,
137
+ label : t ( "page-staking-considerations-pools-6-title" ) ,
133
138
status : permissionlessNodes ,
134
139
} ,
135
140
{
136
- label : < Translation id = "page-staking-considerations-solo-7-title" /> ,
141
+ label : t ( "page-staking-considerations-solo-7-title" ) ,
137
142
status : multiClient ,
138
143
} ,
139
144
{
140
- label : < Translation id = "page-staking-considerations-saas-7-title" /> ,
145
+ label : t ( "page-staking-considerations-saas-7-title" ) ,
141
146
status : executionDiversity ,
142
147
} ,
143
148
{
144
- label : < Translation id = "page-staking-considerations-saas-8-title" /> ,
149
+ label : t ( "page-staking-considerations-saas-8-title" ) ,
145
150
status : consensusDiversity ,
146
151
} ,
147
152
{
148
- label : < Translation id = "page-staking-considerations-solo-8-title" /> ,
153
+ label : t ( "page-staking-considerations-solo-8-title" ) ,
149
154
status : selfCustody ,
150
155
} ,
151
156
{
152
- label : < Translation id = "page-staking-considerations-pools-8-title" /> ,
157
+ label : t ( "page-staking-considerations-pools-8-title" ) ,
153
158
status : liquidityToken ,
154
159
} ,
155
160
{
156
- label : < Translation id = "page-staking-considerations-solo-9-title" /> ,
161
+ label : t ( "page-staking-considerations-solo-9-title" ) ,
157
162
status : economical ,
158
163
} ,
159
- ]
160
-
161
- const filteredData = data . filter (
162
- ( item ) : item is Required < DataType > => ! ! item . status
163
- )
164
+ ] . filter ( ( { status } ) => ! ! status )
164
165
165
166
return (
166
167
< Flex
@@ -180,7 +181,7 @@ export const StakingProductCard: React.FC<ICardProps> = ({
180
181
borderRadius = "base"
181
182
maxH = { 24 }
182
183
>
183
- { ! ! Svg && < Svg fontSize = "2rem" color = "white" /> }
184
+ { ! ! Svg && < Icon as = { Svg } fontSize = "2rem" color = "white" /> }
184
185
< Heading as = "h4" fontSize = "2xl" color = "white" >
185
186
{ name }
186
187
</ Heading >
@@ -203,45 +204,42 @@ export const StakingProductCard: React.FC<ICardProps> = ({
203
204
flex = { 1 }
204
205
alignItems = "flex-start"
205
206
>
206
- { platforms &&
207
- platforms . map ( ( platform , idx ) => (
208
- < StakingBadge type = "platform" key = { idx } >
209
- { platform }
210
- </ StakingBadge >
211
- ) ) }
212
- { ui &&
213
- ui . map ( ( _ui , idx ) => (
214
- < StakingBadge type = "ui" key = { idx } >
215
- { _ui }
216
- </ StakingBadge >
217
- ) ) }
207
+ { platforms . map ( ( platform , idx ) => (
208
+ < StakingBadge type = "platform" key = { idx } >
209
+ { platform }
210
+ </ StakingBadge >
211
+ ) ) }
212
+ { ui . map ( ( _ui , idx ) => (
213
+ < StakingBadge type = "ui" key = { idx } >
214
+ { _ui }
215
+ </ StakingBadge >
216
+ ) ) }
218
217
</ Flex >
219
218
< Box { ...PADDED_DIV_STYLE } py = { 0 } >
220
219
< List m = { 0 } gap = { 3 } >
221
- { filteredData &&
222
- filteredData . map ( ( { label, status } , idx ) => (
223
- < ListItem
224
- as = { Flex }
225
- key = { idx }
226
- textTransform = "uppercase"
227
- fontSize = "xs"
228
- lineHeight = "0.875rem"
229
- letterSpacing = "wider"
230
- my = { 4 }
231
- ms = "auto"
232
- me = { 0 }
233
- gap = "1em"
234
- alignItems = "center"
235
- >
236
- < Status status = { status } />
237
- { label }
238
- </ ListItem >
239
- ) ) }
220
+ { data . map ( ( { label, status } , idx ) => (
221
+ < ListItem
222
+ as = { Flex }
223
+ key = { idx }
224
+ textTransform = "uppercase"
225
+ fontSize = "xs"
226
+ lineHeight = "0.875rem"
227
+ letterSpacing = "wider"
228
+ my = "4"
229
+ ms = "auto"
230
+ me = { 0 }
231
+ gap = "1em"
232
+ alignItems = "center"
233
+ >
234
+ < Status status = { status } />
235
+ { label }
236
+ </ ListItem >
237
+ ) ) }
240
238
</ List >
241
239
</ Box >
242
240
< Box { ...PADDED_DIV_STYLE } >
243
- < ButtonLink to = { url } customEventOptions = { matomo } width = "100%" >
244
- < Translation id = "page-staking-products-get-started" />
241
+ < ButtonLink href = { url } customEventOptions = { matomo } width = "100%" >
242
+ { t ( "page-staking-products-get-started" ) }
245
243
</ ButtonLink >
246
244
</ Box >
247
245
</ Flex >
0 commit comments