Skip to content

Commit 8b95f6e

Browse files
author
soheil
committed
migrate the StakingComparison component to Chakra
1 parent efa2d96 commit 8b95f6e

File tree

1 file changed

+43
-73
lines changed

1 file changed

+43
-73
lines changed

src/components/Staking/StakingComparison.tsx

Lines changed: 43 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
import React, { useContext } from "react"
2-
import styled from "@emotion/styled"
3-
import { useTheme } from "@emotion/react"
1+
import React from "react"
2+
import {
3+
Box,
4+
Flex,
5+
Heading,
6+
Icon,
7+
Text,
8+
useTheme,
9+
VStack,
10+
} from "@chakra-ui/react"
411

512
import Link from "../Link"
613
import Translation from "../Translation"
@@ -12,67 +19,13 @@ import SoloGlyph from "../../assets/staking/staking-glyph-cpu.svg"
1219
import SaasGlyph from "../../assets/staking/staking-glyph-cloud.svg"
1320
import PoolGlyph from "../../assets/staking/staking-glyph-token-wallet.svg"
1421

15-
const GradientContainer = styled.div`
16-
display: flex;
17-
flex-direction: column;
18-
gap: 2rem;
19-
background: linear-gradient(
20-
83.46deg,
21-
rgba(127, 127, 213, 0.2) 7.03%,
22-
rgba(138, 168, 231, 0.2) 52.42%,
23-
rgba(145, 234, 228, 0.2) 98.77%
24-
);
25-
padding: 2rem;
26-
margin-top: 4rem;
27-
@media (max-width: ${({ theme }) => theme.breakpoints.m}) {
28-
padding: 2rem 1.5rem;
29-
}
30-
31-
h3 {
32-
margin: 0 0 0.5rem;
33-
}
34-
`
35-
36-
const Flex = styled.div`
37-
display: flex;
38-
gap: 1.5rem;
39-
@media (max-width: ${({ theme }) => theme.breakpoints.m}) {
40-
flex-direction: column;
41-
}
42-
`
43-
44-
const Glyph = styled.div`
45-
display: flex;
46-
flex-direction: column;
47-
justify-content: flex-start;
48-
align-items: center;
49-
width: 3rem;
50-
max-height: 3rem;
51-
`
52-
53-
const StyledSoloGlyph = styled(SoloGlyph)`
54-
path {
55-
fill: ${({ theme }) => theme.colors.stakingGold};
56-
}
57-
`
58-
const StyledSaasGlyph = styled(SaasGlyph)`
59-
path {
60-
fill: ${({ theme }) => theme.colors.stakingGreen};
61-
}
62-
`
63-
const StyledPoolGlyph = styled(PoolGlyph)`
64-
path {
65-
fill: ${({ theme }) => theme.colors.stakingBlue};
66-
}
67-
`
68-
6922
interface DataType {
7023
title: TranslationKey
7124
linkText: TranslationKey
7225
to: string
7326
matomo: EventOptions
74-
color: any
75-
glyph: any
27+
color: string
28+
glyph: JSX.Element
7629
}
7730

7831
type StakingTypePage = "solo" | "saas" | "pools"
@@ -96,7 +49,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
9649
eventName: "clicked solo staking",
9750
},
9851
color: stakingGold,
99-
glyph: <StyledSoloGlyph />,
52+
glyph: <Icon as={SoloGlyph} color="stakingGold" boxSize="50px" />,
10053
}
10154
const saas: DataType = {
10255
title: "page-staking-saas-with-abbrev",
@@ -108,7 +61,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
10861
eventName: "clicked staking as a service",
10962
},
11063
color: stakingGreen,
111-
glyph: <StyledSaasGlyph />,
64+
glyph: <Icon as={SaasGlyph} color="stakingGreen" boxSize="50px" />,
11265
}
11366
const pools: DataType = {
11467
title: "page-staking-dropdown-pools",
@@ -120,7 +73,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
12073
eventName: "clicked pooled staking",
12174
},
12275
color: stakingBlue,
123-
glyph: <StyledPoolGlyph />,
76+
glyph: <Icon as={PoolGlyph} color="stakingBlue" boxSize="50px" />,
12477
}
12578
const data: {
12679
[key in StakingTypePage]: (DataType & {
@@ -162,19 +115,36 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
162115
const selectedData = data[page]
163116

164117
return (
165-
<GradientContainer className={className}>
166-
<h2>Comparison with other options</h2>
118+
<Flex
119+
direction="column"
120+
gap={8}
121+
bg="linear-gradient(
122+
83.46deg,
123+
rgba(127, 127, 213, 0.2) 7.03%,
124+
rgba(138, 168, 231, 0.2) 52.42%,
125+
rgba(145, 234, 228, 0.2) 98.77%
126+
)"
127+
py={8}
128+
px={{ base: 6, md: 8 }}
129+
mt={16}
130+
className={className}
131+
>
132+
<Heading>Comparison with other options</Heading>
167133
{selectedData.map(
168134
({ title, linkText, to, color, content, glyph, matomo }, idx) => (
169-
<Flex key={idx}>
170-
{!!glyph && <Glyph>{glyph}</Glyph>}
171-
<div>
172-
<h3 style={{ color }}>
135+
<Flex gap={6} direction={{ base: "column", md: "row" }} key={idx}>
136+
{!!glyph && (
137+
<VStack w={12} maxH={12}>
138+
{glyph}
139+
</VStack>
140+
)}
141+
<Box>
142+
<Heading as="h3" color={color} mt={0} mb={2}>
173143
<Translation id={title} />
174-
</h3>
175-
<p>
144+
</Heading>
145+
<Text>
176146
<Translation id={content} />
177-
</p>
147+
</Text>
178148
<Link
179149
onClick={() => {
180150
trackCustomEvent(matomo)
@@ -183,11 +153,11 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
183153
>
184154
<Translation id={linkText} />
185155
</Link>
186-
</div>
156+
</Box>
187157
</Flex>
188158
)
189159
)}
190-
</GradientContainer>
160+
</Flex>
191161
)
192162
}
193163

0 commit comments

Comments
 (0)