1
1
import React from "react"
2
- import styled from "@emotion/styled"
3
2
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"
4
12
5
13
import Translation from "../components/Translation"
6
14
import ButtonLink from "./ButtonLink"
7
- import Emoji from "./OldEmoji "
15
+ import Emoji from "./Emoji "
8
16
import Link from "./Link"
9
17
10
18
import { getImage , getSrc , ImageDataLike } from "../utils/image"
@@ -34,56 +42,6 @@ interface IPropsWithImage extends IPropsBase {
34
42
35
43
export type IProps = IPropsWithImage | IPropsWithSVG
36
44
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
-
87
45
// TODO add ability to download SVGs
88
46
const AssetDownload : React . FC < IProps > = ( {
89
47
alt,
@@ -102,35 +60,77 @@ const AssetDownload: React.FC<IProps> = ({
102
60
const Svg = svg
103
61
104
62
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
+ ) }
109
93
{ ! children && (
110
- < ImageContainer >
94
+ < Center border = "1px" borderColor = "white700" p = { 8 } w = "100%" >
111
95
{ 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 >
114
106
) }
115
107
{ 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" />
119
119
< Translation id = "page-assets-download-artist" />
120
- </ ArtistSubtitle >
120
+ </ Flex >
121
121
{ artistUrl && < Link to = { artistUrl } > { artistName } </ Link > }
122
- { ! artistUrl && < span > { artistName } </ span > }
123
- </ Caption >
122
+ { ! artistUrl && < Text m = { 0 } > { artistName } </ Text > }
123
+ </ Flex >
124
124
) }
125
- </ div >
126
- < ButtonContainer >
125
+ </ Box >
126
+ < Box mt = { 4 } p = { 0 } >
127
127
{ ! Svg && (
128
128
< ButtonLink to = { downloadUrl } >
129
129
< Translation id = "page-assets-download-download" />
130
130
</ ButtonLink >
131
131
) }
132
- </ ButtonContainer >
133
- </ Container >
132
+ </ Box >
133
+ </ Box >
134
134
)
135
135
}
136
136
0 commit comments