import * as React from 'react' import { Transition } from './Transition' import { useReducedMotion } from '../../hooks/useReducedMotion' export interface IOverlayProps { show: boolean onClickOverlay: () => void } export const Overlay: React.FC = props => { const motionDisabled = useReducedMotion() const duration = motionDisabled ? 0 : 250 const onClick = React.useCallback((event: React.MouseEvent) => { if (event.target === event.currentTarget) { props.onClickOverlay() } }, [props.onClickOverlay]) React.useEffect(() => { document.body.classList.toggle('noscroll', props.show) }, [props.show]) return (
{props.children}
) }