/* eslint-disable jsx-a11y/click-events-have-key-events */ import { useLockBodyScroll } from '@app/hooks/useLockBodyScroll'; import { Transition } from '@headlessui/react'; import { XMarkIcon } from '@heroicons/react/24/outline'; import { Fragment, useEffect, useRef, useState } from 'react'; import ReactDOM from 'react-dom'; interface SlideOverProps { show?: boolean; title: React.ReactNode; subText?: string; onClose: () => void; children: React.ReactNode; } const SlideOver = ({ show = false, title, subText, onClose, children, }: SlideOverProps) => { const [isMounted, setIsMounted] = useState(false); const slideoverRef = useRef(null); useLockBodyScroll(show); useEffect(() => { setIsMounted(true); }, []); if (!isMounted) { return null; } return ReactDOM.createPortal( {/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
onClose()} onKeyDown={(e) => { if (e.key === 'Escape') { onClose(); } }} >
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */}
e.stopPropagation()} >

{title}

{subText && (

{subText}

)}
{children}
, document.body ); }; export default SlideOver;