-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDialogTitle.tsx
48 lines (45 loc) · 1.14 KB
/
DialogTitle.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
import { Box, IconButton, DialogTitle as MuiDialogTitle } from "@mui/material";
import CloseIcon from "@mui/icons-material/Close";
import type { DialogTitleProps } from "./DialogTitle.types";
import React from "react";
/**
* This component is based on the material DialogTitle. It supports all the props that the material DialogTitle supports and adds extra functionality to show a close button.
*/
const DialogTitle = ({ children, onClose, ...other }: DialogTitleProps) => {
return (
<MuiDialogTitle
sx={{
display: "flex",
m: 0,
p: 2,
pr: 1
}}
{...other}
>
<Box
sx={{
flexGrow: 1,
overflowWrap: "anywhere"
}}
>
{children}
</Box>
{onClose ? (
<IconButton
aria-label="close"
onClick={onClose}
sx={{
color: theme => theme.palette.grey[500],
flexGrow: 0,
height: 35,
marginTop: -0.3,
width: 35
}}
>
<CloseIcon />
</IconButton>
) : null}
</MuiDialogTitle>
);
};
export default DialogTitle;