2020-08-07 11:27:12 +02:00
|
|
|
import React from 'react';
|
2020-08-19 08:35:26 +02:00
|
|
|
import ReactDOM from 'react-dom';
|
2020-08-07 11:27:12 +02:00
|
|
|
import { useSpring, animated } from 'react-spring';
|
|
|
|
import styles from './Modal.module.css';
|
|
|
|
|
|
|
|
export default function Modal({ title, children }) {
|
|
|
|
const props = useSpring({ opacity: 1, from: { opacity: 0 } });
|
|
|
|
|
2020-08-19 08:35:26 +02:00
|
|
|
return ReactDOM.createPortal(
|
2020-08-07 11:27:12 +02:00
|
|
|
<animated.div className={styles.modal} style={props}>
|
|
|
|
<div className={styles.content}>
|
|
|
|
{title && <div className={styles.header}>{title}</div>}
|
|
|
|
<div className={styles.body}>{children}</div>
|
|
|
|
</div>
|
2020-08-19 08:35:26 +02:00
|
|
|
</animated.div>,
|
|
|
|
document.getElementById('__modals'),
|
2020-08-07 11:27:12 +02:00
|
|
|
);
|
|
|
|
}
|