mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 23:46:28 +00:00
initial commit for new hats app
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user