Skip to content

Commit 058815f

Browse files
authored
Merge pull request #9103 from benlazzero/AssetDownload
Migrate `AssetDownload.tsx` component to Chakra
2 parents 225217f + 8e3b051 commit 058815f

File tree

1 file changed

+69
-69
lines changed

1 file changed

+69
-69
lines changed

src/components/AssetDownload.tsx

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import React from "react"
2-
import styled from "@emotion/styled"
32
import { GatsbyImage } from "gatsby-plugin-image"
3+
import {
4+
Box,
5+
Flex,
6+
Container,
7+
Img,
8+
Center,
9+
Heading,
10+
Text,
11+
} from "@chakra-ui/react"
412

513
import Translation from "../components/Translation"
614
import ButtonLink from "./ButtonLink"
7-
import Emoji from "./OldEmoji"
15+
import Emoji from "./Emoji"
816
import Link from "./Link"
917

1018
import { getImage, getSrc, ImageDataLike } from "../utils/image"
@@ -34,56 +42,6 @@ interface IPropsWithImage extends IPropsBase {
3442

3543
export type IProps = IPropsWithImage | IPropsWithSVG
3644

37-
const Container = styled.div<IHide>`
38-
flex: 1 1 45%;
39-
display: flex;
40-
flex-direction: column;
41-
justify-content: space-between;
42-
margin: 1rem;
43-
opacity: ${(props) => (props.shouldHide ? 0 : 1)};
44-
@media (max-width: ${(props) => props.theme.breakpoints.l}) {
45-
display: ${(props) => (props.shouldHide ? `none` : `flex`)};
46-
}
47-
`
48-
49-
const Image = styled(GatsbyImage)`
50-
align-self: center;
51-
width: 100%;
52-
`
53-
54-
const ImageContainer = styled.div`
55-
border: 1px solid ${(props) => props.theme.colors.white700};
56-
width: 100%;
57-
padding: 2rem;
58-
text-align: center;
59-
display: flex;
60-
justify-content: center;
61-
`
62-
63-
const ArtistSubtitle = styled.div`
64-
display: flex;
65-
font-size: ${(props) => props.theme.fontSizes.m};
66-
color: ${(props) => props.theme.colors.text300};
67-
margin-right: 0.5rem;
68-
`
69-
70-
const Caption = styled.div`
71-
display: flex;
72-
justify-content: flex-start;
73-
margin-bottom: 1rem;
74-
width: 100%;
75-
background: ${(props) => props.theme.colors.background};
76-
border-left: 1px solid ${(props) => props.theme.colors.white700};
77-
border-bottom: 1px solid ${(props) => props.theme.colors.white700};
78-
border-right: 1px solid ${(props) => props.theme.colors.white700};
79-
border-radius: 0px 0px 4px 4px;
80-
padding: 0.5rem 1rem;
81-
`
82-
83-
const ButtonContainer = styled.div`
84-
margin-top: 1rem;
85-
`
86-
8745
// TODO add ability to download SVGs
8846
const AssetDownload: React.FC<IProps> = ({
8947
alt,
@@ -102,35 +60,77 @@ const AssetDownload: React.FC<IProps> = ({
10260
const Svg = svg
10361

10462
return (
105-
<Container shouldHide={shouldHide}>
106-
<h4>{title}</h4>
107-
<div>
108-
{children && <ImageContainer>{children}</ImageContainer>}
63+
<Box
64+
display={{
65+
base: shouldHide ? "none" : "flex",
66+
lg: "flex",
67+
}}
68+
maxW="100%"
69+
minW="170px"
70+
flex="1 1 45%"
71+
flexDirection="column"
72+
justifyContent="space-between"
73+
m={4}
74+
p={0}
75+
opacity={shouldHide ? 0 : 1}
76+
>
77+
<Heading as="h4" fontSize={{ base: "md", md: "xl" }} fontWeight="500">
78+
{title}
79+
</Heading>
80+
<Box>
81+
{children && (
82+
<Flex
83+
border="1px"
84+
borderColor="white700"
85+
w="100%"
86+
p={8}
87+
textAlign="center"
88+
justify="center"
89+
>
90+
{children}
91+
</Flex>
92+
)}
10993
{!children && (
110-
<ImageContainer>
94+
<Center border="1px" borderColor="white700" p={8} w="100%">
11195
{Svg && <Svg alt={alt} />}
112-
{image && <Image image={getImage(image)!} alt={alt} />}
113-
</ImageContainer>
96+
{image && (
97+
<Img
98+
as={GatsbyImage}
99+
image={getImage(image)!}
100+
alt={alt}
101+
w="100%"
102+
alignSelf="center"
103+
/>
104+
)}
105+
</Center>
114106
)}
115107
{artistName && (
116-
<Caption>
117-
<ArtistSubtitle>
118-
<Emoji text=":artist_palette:" mr={`0.5em`} />
108+
<Flex
109+
mb={4}
110+
border="1px"
111+
borderTop="none"
112+
borderColor="white700"
113+
py={2}
114+
px={4}
115+
borderRadius="0 0 4px 4px"
116+
>
117+
<Flex mr={2} fontSize="md" textColor="text300">
118+
<Emoji text=":artist_palette:" mr={2} fontSize="2xl" />
119119
<Translation id="page-assets-download-artist" />
120-
</ArtistSubtitle>
120+
</Flex>
121121
{artistUrl && <Link to={artistUrl}>{artistName}</Link>}
122-
{!artistUrl && <span>{artistName}</span>}
123-
</Caption>
122+
{!artistUrl && <Text m={0}>{artistName}</Text>}
123+
</Flex>
124124
)}
125-
</div>
126-
<ButtonContainer>
125+
</Box>
126+
<Box mt={4} p={0}>
127127
{!Svg && (
128128
<ButtonLink to={downloadUrl}>
129129
<Translation id="page-assets-download-download" />
130130
</ButtonLink>
131131
)}
132-
</ButtonContainer>
133-
</Container>
132+
</Box>
133+
</Box>
134134
)
135135
}
136136

0 commit comments

Comments
 (0)