2025-02-10 16:49:47 +11:00
|
|
|
import React, { ReactNode } from 'react';
|
|
|
|
|
import FocusTrap from 'focus-trap-react';
|
|
|
|
|
import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
|
|
|
|
import { stopPropagation } from '../utils/keyboard';
|
2026-06-19 00:15:35 -04:00
|
|
|
import { ScreenSize, useScreenSizeContext } from '../hooks/useScreenSize';
|
2025-02-10 16:49:47 +11:00
|
|
|
|
|
|
|
|
type Modal500Props = {
|
|
|
|
|
requestClose: () => void;
|
|
|
|
|
children: ReactNode;
|
|
|
|
|
};
|
|
|
|
|
export function Modal500({ requestClose, children }: Modal500Props) {
|
2026-06-19 00:15:35 -04:00
|
|
|
const isMobile = useScreenSizeContext() === ScreenSize.Mobile;
|
2025-02-10 16:49:47 +11:00
|
|
|
return (
|
|
|
|
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
|
|
|
|
<OverlayCenter>
|
|
|
|
|
<FocusTrap
|
|
|
|
|
focusTrapOptions={{
|
|
|
|
|
initialFocus: false,
|
|
|
|
|
clickOutsideDeactivates: true,
|
|
|
|
|
onDeactivate: requestClose,
|
|
|
|
|
escapeDeactivates: stopPropagation,
|
|
|
|
|
}}
|
|
|
|
|
>
|
2026-06-19 00:15:35 -04:00
|
|
|
<Modal
|
|
|
|
|
size="500"
|
|
|
|
|
variant="Background"
|
|
|
|
|
// On mobile expand to fill the viewport. On desktop fall back to the
|
|
|
|
|
// folds `size="500"` width (~50rem) — overriding maxWidth here would
|
|
|
|
|
// squish the two-pane settings layout.
|
|
|
|
|
style={
|
|
|
|
|
isMobile
|
|
|
|
|
? {
|
|
|
|
|
width: '100%',
|
|
|
|
|
height: '100%',
|
|
|
|
|
maxWidth: '100%',
|
|
|
|
|
maxHeight: '100%',
|
|
|
|
|
borderRadius: 0,
|
|
|
|
|
overflow: 'hidden auto',
|
|
|
|
|
}
|
|
|
|
|
: undefined
|
|
|
|
|
}
|
|
|
|
|
>
|
2025-02-10 16:49:47 +11:00
|
|
|
{children}
|
|
|
|
|
</Modal>
|
|
|
|
|
</FocusTrap>
|
|
|
|
|
</OverlayCenter>
|
|
|
|
|
</Overlay>
|
|
|
|
|
);
|
|
|
|
|
}
|