Skip to content

Commit a31cb73

Browse files
committed
refactor: BugBountyPoints to chakra
1 parent 3ed3fd2 commit a31cb73

File tree

1 file changed

+84
-99
lines changed

1 file changed

+84
-99
lines changed

src/components/BugBountyPoints.tsx

Lines changed: 84 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -2,74 +2,16 @@ import React, { useState, useEffect } from "react"
22
import { useTheme } from "@emotion/react"
33
import { useStaticQuery, graphql } from "gatsby"
44
import { GatsbyImage } from "gatsby-plugin-image"
5-
import styled from "@emotion/styled"
65
import axios from "axios"
76

8-
import Emoji from "./OldEmoji"
7+
import Emoji from "./Emoji"
98
import Translation from "./Translation"
10-
import Icon from "./Icon"
119
import Link from "./Link"
1210
import Tooltip from "./Tooltip"
1311

1412
import { getImage } from "../utils/image"
15-
16-
const PointsExchange = styled.div`
17-
flex: 1 1 560px;
18-
padding: 1.5rem;
19-
border: 1px solid ${(props) => props.theme.colors.border};
20-
border-radius: 2px;
21-
margin: 0 2rem;
22-
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
23-
margin: 2rem 0;
24-
}
25-
`
26-
27-
const PointsExchangeLabel = styled.div`
28-
text-transform: uppercase;
29-
font-size: 0.875rem;
30-
margin-bottom: 1rem;
31-
`
32-
33-
const PointsExchangeTitle = styled.h2`
34-
font-family: ${(props) => props.theme.fonts.monospace};
35-
font-size: 1.5rem;
36-
font-weight: 700;
37-
text-transform: uppercase;
38-
margin-top: 0rem;
39-
`
40-
41-
const InfoIcon = styled(Icon)`
42-
margin-left: 0.5rem;
43-
fill: ${(props) => props.theme.colors.text200};
44-
`
45-
46-
const TextNoMargin = styled.p`
47-
margin-bottom: 0rem;
48-
`
49-
50-
const Token = styled(GatsbyImage)`
51-
margin-right: 0.5rem;
52-
`
53-
54-
const TokenValue = styled.p`
55-
font-size: 1.25rem;
56-
margin: 0rem;
57-
margin-right: 1rem;
58-
`
59-
60-
const Row = styled.div`
61-
display: flex;
62-
align-items: center;
63-
flex-wrap: wrap;
64-
`
65-
66-
const ValueRow = styled(Row)`
67-
margin-bottom: 2rem;
68-
@media (max-width: ${(props) => props.theme.breakpoints.s}) {
69-
flex-direction: column;
70-
align-items: flex-start;
71-
}
72-
`
13+
import { Box, Flex, Heading, Icon, Text } from "@chakra-ui/react"
14+
import { MdInfoOutline } from "react-icons/md"
7315

7416
export const TokenLogo = graphql`
7517
fragment TokenLogo on File {
@@ -143,10 +85,10 @@ const BugBountyPoints: React.FC<IProps> = () => {
14385
: 0
14486

14587
const tooltipContent = (
146-
<div>
88+
<Box>
14789
<Translation id="data-provided-by" />{" "}
14890
<Link to="https://www.coingecko.com/en/api">coingecko.com</Link>
149-
</div>
91+
</Box>
15092
)
15193

15294
const data = useStaticQuery(graphql`
@@ -165,57 +107,100 @@ const BugBountyPoints: React.FC<IProps> = () => {
165107
const ethImage = isDarkTheme ? data.ethDark : data.ethLight
166108

167109
return (
168-
<PointsExchange>
169-
<PointsExchangeLabel>
110+
<Box
111+
flex="1 1 560px"
112+
mx={{ base: 0, lg: 8 }}
113+
my={{ base: 8, lg: 0 }}
114+
p={6}
115+
border="1px solid"
116+
borderColor="border"
117+
borderRadius="2px"
118+
textTransform="uppercase"
119+
>
120+
<Box mb={4} fontSize="sm">
170121
<Translation id="page-upgrades-bug-bounty-points-exchange" />{" "}
171122
<Tooltip content={tooltipContent}>
172-
<InfoIcon name="info" size="14" />
123+
<Icon as={MdInfoOutline} fill="text200" boxSize="4" />
173124
</Tooltip>
174-
</PointsExchangeLabel>
175-
<PointsExchangeTitle>
125+
</Box>
126+
<Heading
127+
as="h2"
128+
mt={0}
129+
fontFamily="monospace"
130+
fontSize="2xl"
131+
fontWeight="bold"
132+
>
176133
<Translation id="page-upgrades-bug-bounty-points-point" />
177-
</PointsExchangeTitle>
134+
</Heading>
178135
{state.hasError && (
179-
<ValueRow>
180-
<TokenValue>
136+
<Flex
137+
align={{ base: "start", sm: "center" }}
138+
direction={{ base: "column", sm: "row" }}
139+
wrap="wrap"
140+
mb={8}
141+
>
142+
<Text fontSize="xl" m={0} mr={4}>
181143
<Translation id="page-upgrades-bug-bounty-points-error" />
182-
</TokenValue>
183-
</ValueRow>
144+
</Text>
145+
</Flex>
184146
)}
185147
{isLoading && !state.hasError && (
186-
<ValueRow>
187-
<TokenValue>
148+
<Flex
149+
align={{ base: "start", sm: "center" }}
150+
direction={{ base: "column", sm: "row" }}
151+
wrap="wrap"
152+
mb={8}
153+
>
154+
<Text fontSize="xl" m={0} mr={4}>
188155
<Translation id="page-upgrades-bug-bounty-points-loading" />
189-
</TokenValue>
190-
</ValueRow>
156+
</Text>
157+
</Flex>
191158
)}
192159
{!isLoading && !state.hasError && (
193-
<ValueRow>
194-
<Row>
195-
<Emoji mr={`0.5rem`} text=":dollar:" />
196-
<TokenValue>
160+
<Flex
161+
align={{ base: "start", sm: "center" }}
162+
direction={{ base: "column", sm: "row" }}
163+
wrap="wrap"
164+
mb={8}
165+
gap={2}
166+
>
167+
<Flex align="center" wrap="wrap">
168+
<Emoji fontSize="xl" mr={2} text=":dollar:" />
169+
<Text fontSize="xl" m={0} mr={4}>
197170
<Translation id="page-upgrades-bug-bounty-points-usd" />
198-
</TokenValue>
199-
</Row>
200-
<Row>
201-
<Token image={getImage(data.dai)!} alt="" />
202-
<TokenValue>{pointsInDAI} DAI</TokenValue>
203-
</Row>
204-
<Row>
205-
<Token image={getImage(ethImage)!} alt="" />
206-
<TokenValue>{pointsInETH} ETH</TokenValue>
207-
</Row>
208-
</ValueRow>
171+
</Text>
172+
</Flex>
173+
<Flex align="center" wrap="wrap">
174+
<GatsbyImage
175+
image={getImage(data.dai)!}
176+
style={{ marginRight: "0.5rem" }}
177+
alt=""
178+
/>
179+
<Text fontSize="xl" m={0} mr={4}>
180+
{pointsInDAI} DAI
181+
</Text>
182+
</Flex>
183+
<Flex align="center" wrap="wrap">
184+
<GatsbyImage
185+
image={getImage(ethImage)!}
186+
style={{ marginRight: "0.5rem" }}
187+
alt=""
188+
/>
189+
<Text fontSize="xl" m={0} mr={4}>
190+
{pointsInETH} ETH
191+
</Text>
192+
</Flex>
193+
</Flex>
209194
)}
210-
<p>
195+
<Text>
211196
<Translation id="page-upgrades-bug-bounty-points-payout-desc" />
212-
</p>
213-
<TextNoMargin>
214-
<em>
197+
</Text>
198+
<Text mb={0}>
199+
<Text as="em">
215200
<Translation id="page-upgrades-bug-bounty-points-rights-desc" />
216-
</em>
217-
</TextNoMargin>
218-
</PointsExchange>
201+
</Text>
202+
</Text>
203+
</Box>
219204
)
220205
}
221206

0 commit comments

Comments
 (0)