import { useEffect, type FC, type ReactNode } from 'react'; import { useStyles } from './Mask.style'; type MaskProps = { visible: boolean; children: ReactNode; onMaskClick?: () => void; onClose?: () => void; }; export const Mask: FC = (props) => { const { styles } = useStyles(); useEffect(() => { if (props.visible) { document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; props.onClose?.(); } }, [props.visible]); return props.visible ? (
{props.children}
) : null; };