mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:56:28 +00:00
32 lines
907 B
TypeScript
32 lines
907 B
TypeScript
import React, { MouseEvent, ReactNode, useEffect, useState } from 'react';
|
|
|
|
type Props = {
|
|
onClose: (e: MouseEvent<HTMLElement>) => any,
|
|
children: ReactNode
|
|
};
|
|
|
|
const CustomModal: React.FC<Props> = ({ children, onClose }) => {
|
|
const [isMounted, setIsMounted] = useState(false)
|
|
|
|
useEffect(() => {
|
|
setIsMounted(true)
|
|
|
|
return () => {
|
|
setIsMounted(false)
|
|
}
|
|
}, [])
|
|
|
|
return (
|
|
<>
|
|
<div className={`${isMounted ? 'open' : 'close'} custom-modal-background`} onClick={onClose}>
|
|
<div className={`${isMounted ? 'open' : 'close'} custom-modal`} style={{ translate: '-50% -50%' }}>
|
|
<div className="w-full overflow-y-auto" style={{ maxHeight: '90vh' }}>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
export default CustomModal; |