-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMyImage.js
78 lines (73 loc) · 1.82 KB
/
MyImage.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React, { useState } from "react";
import styled from "styled-components";
const MyImage = ({ imgs = [{ url: "" }] }) => {
const [mainImage, setMainImage] = useState(imgs[0]);
return (
<Wrapper>
<div className="grid grid-four-column">
{imgs.map((curElm, index) => {
return (
<figure>
<img
src={curElm.url}
alt={curElm.filename}
className="box-image--style"
key={index}
onClick={() => setMainImage(curElm)}
/>
</figure>
);
})}
</div>
{/* 2nd column */}
<div className="main-screen">
<img src={mainImage.url} alt={mainImage.filename} />
</div>
</Wrapper>
);
};
const Wrapper = styled.section`
display: grid;
grid-template-columns: 0.4fr 1fr;
gap: 1rem;
.grid {
flex-direction: row;
justify-items: center;
align-items: center;
width: 100%;
gap: 1rem;
/* order: 2; */
img {
max-width: 100%;
max-height: 100%;
background-size: cover;
object-fit: contain;
cursor: pointer;
box-shadow: ${({ theme }) => theme.colors.shadow};
}
}
.main-screen {
display: grid;
place-items: center;
order: 1;
img {
max-width: 100%;
height: auto;
box-shadow: ${({ theme }) => theme.colors.shadow};
}
}
.grid-four-column {
grid-template-columns: 1fr;
grid-template-rows: repeat(4, 1fr);
}
@media (max-width: ${({ theme }) => theme.media.mobile}) {
display: flex;
flex-direction: column;
order: 1;
.grid-four-column {
grid-template-rows: 1fr;
grid-template-columns: repeat(4, 1fr);
}
}
`;
export default MyImage;