frontend/app/CustomDialogTitle.tsx (46 lines of code) (raw):

import { createStyles, Theme, WithStyles, withStyles, } from "@material-ui/core/styles"; import MuiDialogTitle from "@material-ui/core/DialogTitle"; import { IconButton, Typography } from "@material-ui/core"; import CloseIcon from "@material-ui/icons/Close"; import React from "react"; export interface DialogTitleProps extends WithStyles<typeof styles> { id: string; children: React.ReactNode; onClose: () => void; } const styles = (theme: Theme) => createStyles({ root: { margin: 0, padding: theme.spacing(2), }, closeButton: { position: "absolute", right: theme.spacing(1), top: theme.spacing(1), color: theme.palette.grey[500], }, }); const CustomDialogTitle = withStyles(styles)((props: DialogTitleProps) => { const { children, classes, onClose, ...other } = props; return ( <MuiDialogTitle disableTypography className={classes.root} {...other}> <Typography variant="h6">{children}</Typography> {onClose ? ( <IconButton aria-label="close" className={classes.closeButton} onClick={onClose} > <CloseIcon /> </IconButton> ) : null} </MuiDialogTitle> ); }); export default CustomDialogTitle;