fix: make modal use viewport breakpoints (#7246)

This commit is contained in:
David Luzar 2023-11-07 10:10:12 +01:00 committed by GitHub
parent ce7a847668
commit 9006caff39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 15 deletions

View File

@ -33,14 +33,16 @@
color: var(--color-gray-40); color: var(--color-gray-40);
} }
@include isMobile {
top: 1.25rem;
right: 1.25rem;
}
svg { svg {
width: 1.5rem; width: 1.5rem;
height: 1.5rem; height: 1.5rem;
} }
} }
.Dialog--fullscreen {
.Dialog__close {
top: 1.25rem;
right: 1.25rem;
}
}
} }

View File

@ -49,7 +49,7 @@ export const Dialog = (props: DialogProps) => {
const [islandNode, setIslandNode] = useCallbackRefState<HTMLDivElement>(); const [islandNode, setIslandNode] = useCallbackRefState<HTMLDivElement>();
const [lastActiveElement] = useState(document.activeElement); const [lastActiveElement] = useState(document.activeElement);
const { id } = useExcalidrawContainer(); const { id } = useExcalidrawContainer();
const device = useDevice(); const isFullscreen = useDevice().viewport.isMobile;
useEffect(() => { useEffect(() => {
if (!islandNode) { if (!islandNode) {
@ -101,7 +101,9 @@ export const Dialog = (props: DialogProps) => {
return ( return (
<Modal <Modal
className={clsx("Dialog", props.className)} className={clsx("Dialog", props.className, {
"Dialog--fullscreen": isFullscreen,
})}
labelledBy="dialog-title" labelledBy="dialog-title"
maxWidth={getDialogSize(props.size)} maxWidth={getDialogSize(props.size)}
onCloseRequest={onClose} onCloseRequest={onClose}
@ -119,7 +121,7 @@ export const Dialog = (props: DialogProps) => {
title={t("buttons.close")} title={t("buttons.close")}
aria-label={t("buttons.close")} aria-label={t("buttons.close")}
> >
{device.editor.isMobile ? back : CloseIcon} {isFullscreen ? back : CloseIcon}
</button> </button>
<div className="Dialog__content">{props.children}</div> <div className="Dialog__content">{props.children}</div>
</Island> </Island>

View File

@ -59,12 +59,6 @@
&:focus { &:focus {
outline: none; outline: none;
} }
@include isMobile {
max-width: 100%;
border: 0;
border-radius: 0;
}
} }
@keyframes Modal__background__fade-in { @keyframes Modal__background__fade-in {
@ -105,7 +99,7 @@
} }
} }
@include isMobile { .Dialog--fullscreen {
.Modal { .Modal {
padding: 0; padding: 0;
} }
@ -116,6 +110,9 @@
left: 0; left: 0;
right: 0; right: 0;
bottom: 0; bottom: 0;
max-width: 100%;
border: 0;
border-radius: 0;
} }
} }
} }