-
Notifications
You must be signed in to change notification settings - Fork 59
Expand file tree
/
Copy pathFirstShape.js
More file actions
76 lines (73 loc) · 2.05 KB
/
Copy pathFirstShape.js
File metadata and controls
76 lines (73 loc) · 2.05 KB
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
import { Grid } from "@mui/material";
import React, { Fragment, useState } from "react";
import ReactPlayer from "react-player";
import { oneImageBackground } from "./ShapesStyles";
const FirstShape = ({ images, openModal, cover, coverThreePhotos, sharp }) => {
const [paddingTop, setPaddingTop] = useState(0);
const onImageLoad = async ({ target, current }) => {
const calculatedPadding = (target.height / target.width) * 100;
calculatedPadding < 100
? setPaddingTop(calculatedPadding)
: setPaddingTop(100);
};
return (
<Fragment>
<Grid
container
sx={{
maxHeight: "600px",
overflow: "hidden",
}}
>
{images[0].type.includes("image") ? (
<Grid
item
xs={12}
sx={{
...oneImageBackground,
border: !sharp && "2px solid white;",
borderRadius: !sharp && "6px;",
width: 1,
paddingTop: `${
(cover && 100) || (coverThreePhotos && 40) || paddingTop
}%`,
backgroundImage: `url(${images[0].media})`,
backgroundSize: cover || coverThreePhotos ? "cover" : "contain",
}}
onClick={() => openModal(0)}
>
<img
src={images[0].media}
style={{ display: "none" }}
alt=""
onLoad={onImageLoad}
/>
</Grid>
) : (
<Grid
item
xs={12}
sx={{
width: 1,
display: "flex",
alignItems: "center",
justifyContent: "center",
backgroundColor: "black",
}}
onClick={() => openModal(0)}
>
<ReactPlayer
url={images[0].media}
controls
width={"100%"}
style={{
maxHeight: "600px",
}}
/>
</Grid>
)}
</Grid>
</Fragment>
);
};
export default FirstShape;