Skip to content

Commit

Permalink
Add DialogWithCloseButton component and Dialog styling
Browse files Browse the repository at this point in the history
Change-type: minor
  • Loading branch information
myarmolinsky committed Sep 21, 2023
1 parent a123621 commit 5415d77
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/Material/DialogWithCloseButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import {
Dialog,
DialogProps,
IconButton,
DialogTitle,
Typography,
} from '@mui/material';
import CloseIcon from '@mui/icons-material/Close';

export const DialogWithCloseButton = ({
children,
onClose,
title,
...other
}: Omit<DialogProps, 'title'> & {
title: DialogProps['title'] | JSX.Element;
}) => {
return (
<Dialog onClose={onClose} {...other}>
{title != null && (
<DialogTitle
sx={{
display: 'flex',
justifyContent: 'space-between',
alignItems: 'flex-start',
}}
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
}}
>
{title}
{onClose ? (
<IconButton
aria-label="close"
onClick={(e) => {
onClose(e, 'backdropClick');
}}
sx={{
color: (theme) => theme.palette.grey[500],
}}
>
<CloseIcon />
</IconButton>
) : null}
</DialogTitle>
)}
{children}
</Dialog>
);
};
3 changes: 3 additions & 0 deletions src/Material/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { DialogWithCloseButton } from './DialogWithCloseButton';

export { DialogWithCloseButton };
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,5 @@ export {
useAnalyticsContext,
} from './contexts/AnalyticsContext';
export * as Material from '@mui/material';
export * as CustomMaterial from './Material';
export * as IconsMaterial from '@mui/icons-material';
23 changes: 23 additions & 0 deletions src/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,29 @@ export const theme = createTheme({
},
},
},
MuiDialogTitle: {
styleOverrides: {
root: {
padding: '24px',
fontSize: '24px',
},
},
},
MuiDialogContent: {
styleOverrides: {
root: {
padding: '0px 24px',
margin: '24px 0px',

This comment has been minimized.

Copy link
@drskullster

drskullster Sep 21, 2023

Contributor

@myarmolinsky what are you solving with the padding-top at 0 and margin-top at 24px?

I've noticed a big gap between the dialog heading and the content that I don't see in PR screenshots:

image

},
},
},
MuiDialogActions: {
styleOverrides: {
root: {
padding: '0px 24px 24px',
},
},
},
MuiCard: {
styleOverrides: {
root: {
Expand Down

0 comments on commit 5415d77

Please sign in to comment.