Skip to content

Commit 805e57a

Browse files
authored
Merge pull request #9017 from soheil555/feat/staking-stats-box
migrate the `StakingStatsBox` to Chakra UI
2 parents 84b42dd + 5261938 commit 805e57a

File tree

1 file changed

+57
-60
lines changed

1 file changed

+57
-60
lines changed

src/components/Staking/StakingStatsBox.tsx

Lines changed: 57 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Import libraries
2-
import React, { useState, useEffect } from "react"
3-
import styled from "@emotion/styled"
2+
import React, { useState, useEffect, ReactNode } from "react"
3+
import { MdInfoOutline } from "react-icons/md"
44
import { useIntl } from "react-intl"
5-
import { Spinner } from "@chakra-ui/react"
5+
import { Code, Flex, Icon, Spinner, VStack } from "@chakra-ui/react"
66
// Import components
77
import Translation from "../Translation"
88
import Tooltip from "../Tooltip"
99
import Link from "../Link"
10-
import Icon from "../Icon"
1110
// Import utilities
1211
import { Lang } from "../../utils/languages"
1312
import { getData } from "../../utils/cache"
@@ -18,61 +17,51 @@ const NA_ERROR = "n/a"
1817
const ZERO = "0"
1918
const MAX_EFFECTIVE_BALANCE = 32
2019

21-
// Styled components
22-
const Container = styled.div`
23-
display: flex;
24-
@media (max-width: ${({ theme }) => theme.breakpoints.m}) {
25-
flex-direction: column;
26-
}
27-
`
28-
29-
const Cell = styled.div`
30-
display: flex;
31-
flex-direction: column;
32-
align-items: center;
33-
padding: 1rem 2rem;
34-
border-left: 1px solid ${({ theme }) => theme.colors.preBorder};
35-
@media (max-width: ${({ theme }) => theme.breakpoints.m}) {
36-
border-left: none;
37-
border-top: 1px solid #33333355;
38-
}
39-
&:first-child {
40-
border-left: none;
41-
border-top: none;
42-
}
43-
`
44-
45-
const Value = styled.code`
46-
font-weight: 700;
47-
font-size: 2rem;
48-
background: none;
49-
display: flex;
50-
align-items: center;
51-
text-align: center;
52-
text-transform: uppercase;
53-
color: ${({ theme }) => theme.colors.primary};
54-
`
20+
const Cell: React.FC<{ children: ReactNode }> = ({ children }) => {
21+
return (
22+
<VStack
23+
spacing={2}
24+
py={4}
25+
px={8}
26+
borderLeft={{ md: "1px" }}
27+
borderTop={{ base: "1px", md: "none" }}
28+
// `!important` needed to force an override of the user-agent
29+
borderColor="preBorder !important"
30+
_first={{
31+
borderLeft: "none",
32+
borderTop: "none",
33+
}}
34+
>
35+
{children}
36+
</VStack>
37+
)
38+
}
5539

56-
const Label = styled.div`
57-
display: flex;
58-
flex-wrap: nowrap;
59-
align-items: center;
60-
text-transform: uppercase;
61-
font-size: 0.875rem;
62-
margin-top: 0.5rem;
63-
`
40+
const Value: React.FC<{ children: ReactNode; title: string }> = ({
41+
children,
42+
title,
43+
}) => {
44+
return (
45+
<Code
46+
title={title}
47+
fontWeight="bold"
48+
fontSize="2rem"
49+
background="none"
50+
color="primary"
51+
p={0}
52+
>
53+
{children}
54+
</Code>
55+
)
56+
}
6457

65-
const StyledIcon = styled(Icon)`
66-
fill: ${({ theme }) => theme.colors.text};
67-
margin-inline-start: 0.5rem;
68-
@media (max-width: ${({ theme }) => theme.breakpoints.l}) {
69-
}
70-
&:hover,
71-
&:active,
72-
&:focus {
73-
fill: ${({ theme }) => theme.colors.primary};
74-
}
75-
`
58+
const Label: React.FC<{ children: ReactNode }> = ({ children }) => {
59+
return (
60+
<Flex alignItems="center" textTransform="uppercase" fontSize="sm">
61+
{children}
62+
</Flex>
63+
)
64+
}
7665

7766
// BeaconchainTooltip component
7867
const BeaconchainTooltip = ({ isEthStore }: { isEthStore?: boolean }) => (
@@ -87,7 +76,15 @@ const BeaconchainTooltip = ({ isEthStore }: { isEthStore?: boolean }) => (
8776
</div>
8877
}
8978
>
90-
<StyledIcon name="info" size="16" />
79+
<Icon
80+
as={MdInfoOutline}
81+
color="text"
82+
marginInlineStart={2}
83+
_hover={{ color: "primary" }}
84+
_active={{ color: "primary" }}
85+
_focus={{ color: "primary" }}
86+
boxSize={4}
87+
/>
9188
</Tooltip>
9289
)
9390

@@ -148,7 +145,7 @@ const StakingStatsBox: React.FC<IProps> = () => {
148145
}, [intl.locale])
149146

150147
return (
151-
<Container>
148+
<Flex direction={{ base: "column", md: "row" }}>
152149
<Cell>
153150
{totalEth === ZERO ? (
154151
<Spinner />
@@ -186,7 +183,7 @@ const StakingStatsBox: React.FC<IProps> = () => {
186183
<BeaconchainTooltip isEthStore />
187184
</Label>
188185
</Cell>
189-
</Container>
186+
</Flex>
190187
)
191188
}
192189

0 commit comments

Comments
 (0)