-
Notifications
You must be signed in to change notification settings - Fork 503
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #674 from rowyio/rc
v2.5.0
- Loading branch information
Showing
51 changed files
with
1,294 additions
and
232 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
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
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
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,110 @@ | ||
import { ReactNode, useState } from "react"; | ||
|
||
import { | ||
Dialog, | ||
DialogProps, | ||
Slide, | ||
IconButton, | ||
Container, | ||
} from "@mui/material"; | ||
import CloseIcon from "@mui/icons-material/Close"; | ||
|
||
import ScrollableDialogContent, { | ||
IScrollableDialogContentProps, | ||
} from "./ScrollableDialogContent"; | ||
|
||
export interface IFullScreenModalProps | ||
extends Partial<Omit<DialogProps, "title">> { | ||
onClose: (setOpen: React.Dispatch<React.SetStateAction<boolean>>) => void; | ||
disableBackdropClick?: boolean; | ||
disableEscapeKeyDown?: boolean; | ||
|
||
"aria-labelledby": DialogProps["aria-labelledby"]; | ||
header?: ReactNode; | ||
children?: ReactNode; | ||
footer?: ReactNode; | ||
|
||
hideCloseButton?: boolean; | ||
ScrollableDialogContentProps?: Partial<IScrollableDialogContentProps>; | ||
} | ||
|
||
export default function FullScreenModal({ | ||
onClose, | ||
disableBackdropClick, | ||
disableEscapeKeyDown, | ||
header, | ||
children, | ||
footer, | ||
hideCloseButton, | ||
ScrollableDialogContentProps, | ||
...props | ||
}: IFullScreenModalProps) { | ||
const [open, setOpen] = useState(true); | ||
const handleClose: NonNullable<DialogProps["onClose"]> = (_, reason) => { | ||
if ( | ||
(disableBackdropClick && reason === "backdropClick") || | ||
(disableEscapeKeyDown && reason === "escapeKeyDown") | ||
) { | ||
setEmphasizeCloseButton(true); | ||
return; | ||
} | ||
|
||
setOpen(false); | ||
setEmphasizeCloseButton(false); | ||
setTimeout(() => onClose(setOpen), 300); | ||
}; | ||
|
||
const [emphasizeCloseButton, setEmphasizeCloseButton] = useState(false); | ||
|
||
return ( | ||
<Dialog | ||
fullScreen | ||
open={open} | ||
onClose={handleClose} | ||
TransitionComponent={Slide} | ||
TransitionProps={{ direction: "up" } as any} | ||
{...props} | ||
> | ||
<Container | ||
sx={{ | ||
display: "flex", | ||
flexDirection: "column", | ||
height: "100%", | ||
pt: { xs: "var(--dialog-spacing)", xl: 6 }, | ||
}} | ||
> | ||
{!hideCloseButton && ( | ||
<IconButton | ||
onClick={handleClose as any} | ||
aria-label="Close" | ||
sx={{ | ||
position: "absolute", | ||
top: (theme) => theme.spacing(1), | ||
right: (theme) => theme.spacing(1), | ||
|
||
bgcolor: emphasizeCloseButton ? "error.main" : undefined, | ||
color: emphasizeCloseButton ? "error.contrastText" : undefined, | ||
"&:hover": emphasizeCloseButton | ||
? { bgcolor: "error.dark" } | ||
: undefined, | ||
}} | ||
className="dialog-close" | ||
> | ||
<CloseIcon /> | ||
</IconButton> | ||
)} | ||
|
||
{header} | ||
|
||
<ScrollableDialogContent | ||
style={{ padding: 0 }} | ||
{...ScrollableDialogContentProps} | ||
> | ||
{children} | ||
</ScrollableDialogContent> | ||
|
||
{footer} | ||
</Container> | ||
</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
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
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
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
Oops, something went wrong.