Skip to content

Commit bbe9ad5

Browse files
hextrazaSebastian Benjaminbbimber
authored
Add video modal component (#235)
Co-authored-by: Sebastian Benjamin <sebastiancbenjamin@gmail.com> Co-authored-by: bbimber <bbimber@gmail.com>
1 parent 13bf965 commit bbe9ad5

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import React, { useState } from 'react';
2+
import Dialog from '@mui/material/Dialog';
3+
import Button from '@mui/material/Button';
4+
import Tooltip from '@mui/material/Tooltip';
5+
import HelpIcon from '@mui/icons-material/Help';
6+
import CloseIcon from '@mui/icons-material/Close';
7+
8+
export default function VideoModal({ videoURL, hoverText = '' }) {
9+
const [open, setOpen] = useState(false);
10+
11+
const handleOpen = () => {
12+
setOpen(true);
13+
};
14+
15+
const handleClose = () => {
16+
setOpen(false);
17+
};
18+
19+
const buttonContent = (
20+
<Button
21+
onClick={handleOpen}
22+
disableRipple
23+
style={{
24+
padding: 0,
25+
minWidth: 0,
26+
backgroundColor: 'transparent',
27+
}}
28+
>
29+
<HelpIcon />
30+
</Button>
31+
);
32+
33+
return (
34+
<div>
35+
{hoverText ? (
36+
<Tooltip title={hoverText}>
37+
{buttonContent}
38+
</Tooltip>
39+
) : (
40+
buttonContent
41+
)}
42+
<Dialog
43+
open={open}
44+
onClose={handleClose}
45+
PaperProps={{
46+
style: {
47+
backgroundColor: 'transparent',
48+
boxShadow: 'none',
49+
position: 'relative',
50+
},
51+
}}
52+
>
53+
<CloseIcon
54+
style={{
55+
position: 'absolute',
56+
top: 10,
57+
right: 10,
58+
zIndex: 1,
59+
cursor: 'pointer',
60+
color: 'white',
61+
backgroundColor: 'rgba(0, 0, 0, 0.4)',
62+
borderRadius: '50%'
63+
}}
64+
onClick={handleClose}
65+
/>
66+
<video
67+
width="100%"
68+
controls
69+
>
70+
<source src={videoURL} type="video/mp4" />
71+
Your browser does not support the video tag.
72+
</video>
73+
</Dialog>
74+
</div>
75+
);
76+
}

0 commit comments

Comments
 (0)