CustomDialogTitle.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import {
  2. DialogTitleProps,
  3. makeStyles,
  4. Theme,
  5. Typography,
  6. } from '@material-ui/core';
  7. import MuiDialogTitle from '@material-ui/core/DialogTitle';
  8. import icons from '../icons/Icons';
  9. const getStyles = makeStyles((theme: Theme) => ({
  10. root: {
  11. margin: 0,
  12. display: 'flex',
  13. justifyContent: 'space-between',
  14. alignItems: 'center',
  15. },
  16. // closeButton: {
  17. // padding: theme.spacing(1),
  18. // },
  19. icon: {
  20. fontSize: '24px',
  21. color: '#010e29',
  22. cursor: 'pointer',
  23. },
  24. }));
  25. interface IProps extends DialogTitleProps {
  26. onClose?: () => void;
  27. }
  28. const CustomDialogTitle = (props: IProps) => {
  29. const { children, classes = { root: '' }, onClose, ...other } = props;
  30. const innerClass = getStyles();
  31. const ClearIcon = icons.clear;
  32. return (
  33. <MuiDialogTitle
  34. disableTypography
  35. className={`${innerClass.root} ${classes.root}`}
  36. {...other}
  37. >
  38. <Typography variant="h5">{children}</Typography>
  39. {onClose ? (
  40. <ClearIcon classes={{ root: innerClass.icon }} onClick={onClose} />
  41. ) : null}
  42. </MuiDialogTitle>
  43. );
  44. };
  45. export default CustomDialogTitle;