mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-27 12:26:29 -08:00
34 lines
1016 B
TypeScript
34 lines
1016 B
TypeScript
import type { ReactNode } from 'react';
|
|
import { useRef } from 'react';
|
|
import FocusTrap from 'focus-trap-react';
|
|
import { Modal, Overlay, OverlayBackdrop, OverlayCenter } from 'folds';
|
|
import { stopPropagation } from '$utils/keyboard';
|
|
|
|
type Modal500Props = {
|
|
requestClose: () => void;
|
|
children: ReactNode;
|
|
};
|
|
export function Modal500({ requestClose, children }: Modal500Props) {
|
|
const modalRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
return (
|
|
<Overlay open backdrop={<OverlayBackdrop />}>
|
|
<OverlayCenter>
|
|
<FocusTrap
|
|
focusTrapOptions={{
|
|
initialFocus: false,
|
|
fallbackFocus: () => modalRef.current ?? document.body,
|
|
clickOutsideDeactivates: true,
|
|
onDeactivate: requestClose,
|
|
escapeDeactivates: stopPropagation,
|
|
}}
|
|
>
|
|
<Modal ref={modalRef} tabIndex={-1} size="500" variant="Background">
|
|
{children}
|
|
</Modal>
|
|
</FocusTrap>
|
|
</OverlayCenter>
|
|
</Overlay>
|
|
);
|
|
}
|