-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
DialogWithTitle.tsx
63 lines (59 loc) · 1.55 KB
/
DialogWithTitle.tsx
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
import CloseIcon from "@mui/icons-material/Close";
import { Dialog, IconButton, Theme, Typography } from "@mui/material";
import { WithStyles } from "@mui/styles";
import createStyles from "@mui/styles/createStyles";
import withStyles from "@mui/styles/withStyles";
import React, { PropsWithChildren } from "react";
const styles = (theme: Theme) =>
createStyles({
paper: {
padding: theme.spacing(3),
},
closeButton: {
position: "absolute",
right: theme.spacing(1.5),
top: theme.spacing(1.5),
zIndex: 1,
},
title: {
borderBottomColor: theme.palette.divider,
borderBottomStyle: "solid",
borderBottomWidth: 1,
fontSize: "1.5rem",
lineHeight: 1,
marginBottom: theme.spacing(3),
paddingBottom: theme.spacing(3),
},
});
type Props = {
handleClose: () => void;
title: string;
};
class DialogWithTitle extends React.Component<
PropsWithChildren<Props> & WithStyles<typeof styles>
> {
render() {
const { classes, handleClose, title } = this.props;
return (
<Dialog
classes={{ paper: classes.paper }}
fullWidth
maxWidth="md"
onClose={handleClose}
open
scroll="body"
>
<IconButton
className={classes.closeButton}
onClick={handleClose}
size="large"
>
<CloseIcon />
</IconButton>
<Typography className={classes.title}>{title}</Typography>
{this.props.children}
</Dialog>
);
}
}
export default withStyles(styles)(DialogWithTitle);