-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add DialogWithCloseButton component and Dialog styling
Change-type: minor
- Loading branch information
1 parent
a123621
commit 5415d77
Showing
4 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { DialogWithCloseButton } from './DialogWithCloseButton'; | ||
|
||
export { DialogWithCloseButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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: