2021-09-15 03:05:49 +02:00
|
|
|
import React from "react";
|
2021-09-17 01:23:03 +02:00
|
|
|
import { Theme } from "@mui/material";
|
|
|
|
import makeStyles from "@mui/styles/makeStyles";
|
|
|
|
import createStyles from "@mui/styles/createStyles";
|
|
|
|
import M from "@mui/material/Modal";
|
|
|
|
import Backdrop from "@mui/material/Backdrop";
|
|
|
|
import Fade from "@mui/material/Fade";
|
2021-09-15 03:05:49 +02:00
|
|
|
|
|
|
|
const useStyles = makeStyles((theme: Theme) =>
|
|
|
|
createStyles({
|
|
|
|
modal: {
|
|
|
|
display: "flex",
|
|
|
|
alignItems: "center",
|
|
|
|
justifyContent: "center",
|
|
|
|
},
|
|
|
|
paper: {
|
|
|
|
backgroundColor: theme.palette.background.paper,
|
|
|
|
border: "2px solid " + theme.palette.primary.main,
|
|
|
|
boxShadow: theme.shadows[5],
|
2021-09-17 01:23:03 +02:00
|
|
|
padding: 2,
|
2021-09-15 03:47:42 +02:00
|
|
|
maxWidth: "80%",
|
|
|
|
maxHeight: "80%",
|
|
|
|
overflow: "auto",
|
|
|
|
"&::-webkit-scrollbar": {
|
|
|
|
// webkit
|
|
|
|
display: "none",
|
|
|
|
},
|
|
|
|
scrollbarWidth: "none", // firefox
|
2021-09-15 03:05:49 +02:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
open: boolean;
|
2021-09-15 03:47:42 +02:00
|
|
|
onClose: () => void;
|
|
|
|
children: JSX.Element[] | JSX.Element | React.ReactElement[] | React.ReactElement;
|
2021-09-15 03:05:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export const Modal = (props: IProps): React.ReactElement => {
|
|
|
|
const classes = useStyles();
|
|
|
|
return (
|
|
|
|
<M
|
|
|
|
open={props.open}
|
2021-09-15 03:47:42 +02:00
|
|
|
onClose={props.onClose}
|
2021-09-15 03:05:49 +02:00
|
|
|
closeAfterTransition
|
|
|
|
className={classes.modal}
|
|
|
|
BackdropComponent={Backdrop}
|
|
|
|
BackdropProps={{
|
2021-09-15 03:47:42 +02:00
|
|
|
timeout: 100,
|
2021-09-15 03:05:49 +02:00
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Fade in={props.open}>
|
|
|
|
<div className={classes.paper}>{props.children}</div>
|
|
|
|
</Fade>
|
|
|
|
</M>
|
|
|
|
);
|
|
|
|
};
|