Skip to content

Commit 4d308c4

Browse files
authored
Merge pull request #9046 from soheil555/feat/staking-comparison-to-chakra
migrate the `StakingComparison` component to Chakra
2 parents 805e57a + 48b9fc6 commit 4d308c4

File tree

1 file changed

+41
-73
lines changed

1 file changed

+41
-73
lines changed

src/components/Staking/StakingComparison.tsx

Lines changed: 41 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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 { Box, Flex, Heading, Icon, Text, useTheme } from "@chakra-ui/react"
43

54
import Link from "../Link"
65
import Translation from "../Translation"
@@ -12,67 +11,13 @@ import SoloGlyph from "../../assets/staking/staking-glyph-cpu.svg"
1211
import SaasGlyph from "../../assets/staking/staking-glyph-cloud.svg"
1312
import PoolGlyph from "../../assets/staking/staking-glyph-token-wallet.svg"
1413

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-
6914
interface DataType {
7015
title: TranslationKey
7116
linkText: TranslationKey
7217
to: string
7318
matomo: EventOptions
74-
color: any
75-
glyph: any
19+
color: string
20+
glyph: JSX.Element
7621
}
7722

7823
type StakingTypePage = "solo" | "saas" | "pools"
@@ -96,7 +41,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
9641
eventName: "clicked solo staking",
9742
},
9843
color: stakingGold,
99-
glyph: <StyledSoloGlyph />,
44+
glyph: <Icon as={SoloGlyph} color="stakingGold" boxSize="50px" />,
10045
}
10146
const saas: DataType = {
10247
title: "page-staking-saas-with-abbrev",
@@ -108,7 +53,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
10853
eventName: "clicked staking as a service",
10954
},
11055
color: stakingGreen,
111-
glyph: <StyledSaasGlyph />,
56+
glyph: <Icon as={SaasGlyph} color="stakingGreen" w="50px" h="28px" />,
11257
}
11358
const pools: DataType = {
11459
title: "page-staking-dropdown-pools",
@@ -120,7 +65,7 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
12065
eventName: "clicked pooled staking",
12166
},
12267
color: stakingBlue,
123-
glyph: <StyledPoolGlyph />,
68+
glyph: <Icon as={PoolGlyph} color="stakingBlue" w="50px" h="39px" />,
12469
}
12570
const data: {
12671
[key in StakingTypePage]: (DataType & {
@@ -162,19 +107,42 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
162107
const selectedData = data[page]
163108

164109
return (
165-
<GradientContainer className={className}>
166-
<h2>Comparison with other options</h2>
110+
<Flex
111+
direction="column"
112+
gap={8}
113+
bg="linear-gradient(
114+
83.46deg,
115+
rgba(127, 127, 213, 0.2) 7.03%,
116+
rgba(138, 168, 231, 0.2) 52.42%,
117+
rgba(145, 234, 228, 0.2) 98.77%
118+
)"
119+
py={8}
120+
px={{ base: 6, md: 8 }}
121+
mt={16}
122+
className={className}
123+
>
124+
<Heading fontSize="2rem">Comparison with other options</Heading>
167125
{selectedData.map(
168126
({ title, linkText, to, color, content, glyph, matomo }, idx) => (
169-
<Flex key={idx}>
170-
{!!glyph && <Glyph>{glyph}</Glyph>}
171-
<div>
172-
<h3 style={{ color }}>
127+
<Flex gap={6} direction={{ base: "column", md: "row" }} key={idx}>
128+
{!!glyph && (
129+
<Flex
130+
direction="column"
131+
justify="flex-start"
132+
align="center"
133+
w={12}
134+
maxH={12}
135+
>
136+
{glyph}
137+
</Flex>
138+
)}
139+
<Box>
140+
<Heading as="h3" fontSize="2xl" color={color} mt={0} mb={2}>
173141
<Translation id={title} />
174-
</h3>
175-
<p>
142+
</Heading>
143+
<Text>
176144
<Translation id={content} />
177-
</p>
145+
</Text>
178146
<Link
179147
onClick={() => {
180148
trackCustomEvent(matomo)
@@ -183,11 +151,11 @@ const StakingComparison: React.FC<IProps> = ({ page, className }) => {
183151
>
184152
<Translation id={linkText} />
185153
</Link>
186-
</div>
154+
</Box>
187155
</Flex>
188156
)
189157
)}
190-
</GradientContainer>
158+
</Flex>
191159
)
192160
}
193161

0 commit comments

Comments
 (0)