Skip to content

Commit 82037ae

Browse files
committed
ProductList.tsx refactor to ChakraUI
1 parent 8f7ff0b commit 82037ae

File tree

1 file changed

+58
-84
lines changed

1 file changed

+58
-84
lines changed

src/components/ProductList.tsx

Lines changed: 58 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,9 @@
11
import React from "react"
2-
import styled from "@emotion/styled"
32
import { GatsbyImage } from "gatsby-plugin-image"
43

54
import ButtonLink from "./ButtonLink"
65
import Translation from "./Translation"
7-
8-
const Product = styled.div`
9-
width: 100%;
10-
`
11-
12-
const Item = styled.div`
13-
display: flex;
14-
color: ${(props) => props.theme.colors.text} !important;
15-
margin-bottom: 1px;
16-
margin-top: 2rem;
17-
@media (max-width: ${(props) => props.theme.breakpoints.s}) {
18-
align-items: flex-start;
19-
}
20-
`
21-
22-
const ItemTitle = styled.div``
23-
24-
const CategoryTitle = styled.h3`
25-
border-bottom: 2px solid ${(props) => props.theme.colors.border};
26-
padding-bottom: 1rem;
27-
margin-bottom: 0rem;
28-
`
29-
30-
const TextContent = styled.div`
31-
padding-bottom: 1rem;
32-
width: 100%;
33-
display: flex;
34-
align-items: center;
35-
margin-left: 1.5rem;
36-
justify-content: space-between;
37-
border-bottom: 1px solid ${(props) => props.theme.colors.border};
38-
@media (max-width: ${(props) => props.theme.breakpoints.s}) {
39-
flex-direction: column;
40-
align-items: flex-start;
41-
margin-left: 1rem;
42-
}
43-
`
44-
45-
const ItemDesc = styled.div`
46-
font-size: ${(props) => props.theme.fontSizes.s};
47-
margin-bottom: 0;
48-
opacity: 0.6;
49-
`
50-
51-
const ImageContainer = styled.div`
52-
width: 80px;
53-
`
54-
55-
const LeftContainer = styled.div`
56-
display: flex;
57-
flex-direction: column;
58-
`
59-
60-
const Image = styled(GatsbyImage)`
61-
box-shadow: ${(props) => props.theme.colors.tableBoxShadow};
62-
border-radius: 2px;
63-
`
64-
65-
const StyledButton = styled(ButtonLink)`
66-
margin-left: 2rem;
67-
padding: 0.25rem 1.5rem;
68-
border-radius: 2px;
69-
@media (max-width: ${(props) => props.theme.breakpoints.s}) {
70-
margin-top: 1rem;
71-
margin-left: 0rem;
72-
}
73-
`
6+
import { Box, Flex, Heading } from "@chakra-ui/react"
747

758
export interface Content {
769
title: string
@@ -87,27 +20,68 @@ export interface IProps {
8720
}
8821

8922
const ProductList: React.FC<IProps> = ({ content, category }) => (
90-
<Product>
91-
<CategoryTitle>{category}</CategoryTitle>
23+
<Box width="full">
24+
<Heading
25+
as="h3"
26+
borderBottom="2px solid"
27+
borderColor="border"
28+
paddingBottom={4}
29+
marginBottom={0}
30+
>
31+
{category}
32+
</Heading>
9233
{content.map(({ title, description, link, image, alt, id }, idx) => (
93-
<Item key={id || idx}>
94-
<ImageContainer>
95-
{image && <Image image={image} alt={alt} />}
96-
</ImageContainer>
97-
<TextContent>
98-
<LeftContainer>
99-
<ItemTitle>{title}</ItemTitle>
100-
<ItemDesc>{description}</ItemDesc>
101-
</LeftContainer>
34+
<Flex
35+
key={id || idx}
36+
color="text"
37+
marginBottom="px"
38+
marginTop={8}
39+
alignItems={{ sm: "flex-start" }}
40+
>
41+
<Box width="5rem">
42+
{image && (
43+
<Box
44+
as={GatsbyImage}
45+
image={image}
46+
alt={alt}
47+
boxShadow="tableBoxShadow"
48+
borderRadius="sm"
49+
/>
50+
)}
51+
</Box>
52+
<Flex
53+
paddingBottom={4}
54+
width="full"
55+
alignItems={{ base: "flex-start", sm: "center" }}
56+
marginLeft={{ base: 6, sm: 4 }}
57+
justifyContent="space-between"
58+
borderBottom="1px solid"
59+
borderColor="border"
60+
flexDir={{ base: "column", sm: "row" }}
61+
>
62+
<Box flexDir="column">
63+
<Box>{title}</Box>
64+
<Box fontSize="sm" marginBottom={0} opacity="0.6">
65+
{description}
66+
</Box>
67+
</Box>
10268
{link && (
103-
<StyledButton variant="outline" to={link}>
69+
<ButtonLink
70+
variant="outline"
71+
to={link}
72+
marginLeft={{ base: 0, sm: 8 }}
73+
paddingY={1}
74+
paddingX={6}
75+
borderRadius="sm"
76+
marginTop={{ base: 4, sm: 0 }}
77+
>
10478
<Translation id="page-dapps-ready-button" />
105-
</StyledButton>
79+
</ButtonLink>
10680
)}
107-
</TextContent>
108-
</Item>
81+
</Flex>
82+
</Flex>
10983
))}
110-
</Product>
84+
</Box>
11185
)
11286

11387
export default ProductList

0 commit comments

Comments
 (0)