bitburner-src/src/ui/React/Modal.tsx

51 lines
1.4 KiB
TypeScript
Raw Normal View History

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 Fade from "@mui/material/Fade";
2021-09-18 19:29:01 +02:00
import Box from "@mui/material/Box";
2021-09-15 03:05:49 +02:00
const useStyles = makeStyles((theme: Theme) =>
createStyles({
modal: {
display: "flex",
alignItems: "center",
justifyContent: "center",
},
paper: {
2021-09-19 06:46:39 +02:00
backgroundColor: theme.palette.background.default,
2021-09-15 03:05:49 +02:00
border: "2px solid " + theme.palette.primary.main,
2021-09-19 06:46:39 +02:00
boxShadow: `0px 3px 5px -1px ${theme.palette.primary.dark},0px 5px 8px 0px ${theme.palette.primary.dark},0px 1px 14px 0px ${theme.palette.primary.dark}`,
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 (
2021-09-18 19:29:01 +02:00
<M open={props.open} onClose={props.onClose} closeAfterTransition className={classes.modal}>
2021-09-15 03:05:49 +02:00
<Fade in={props.open}>
2021-09-18 19:29:01 +02:00
<div className={classes.paper}>
<Box sx={{ m: 2 }}>{props.children}</Box>
</div>
2021-09-15 03:05:49 +02:00
</Fade>
</M>
);
};