1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
import { Component, ReactChildren } from 'react';
import ReactModal from 'react-modal';
import classnames from 'classnames';
import injectCSS from 'react-jss';
import { mdiClose } from '@mdi/js';
import { Icon } from '../icon';
import styles from './styles';
type Props = {
children: ReactChildren;
className: string;
classes: any;
isOpen: boolean;
portal: string;
close: () => void;
shouldCloseOnOverlayClick: boolean;
showClose: boolean;
};
class Modal extends Component<Props> {
static defaultProps = {
className: null,
portal: 'modal-portal',
shouldCloseOnOverlayClick: false,
showClose: true,
};
render() {
const {
children,
className,
classes,
isOpen,
portal,
close,
shouldCloseOnOverlayClick,
showClose,
} = this.props;
return (
<ReactModal
isOpen={isOpen}
className={classnames({
[`${classes.modal}`]: true,
[`${className}`]: className,
})}
portalClassName={classes.component}
overlayClassName={classes.overlay}
portal={portal}
onRequestClose={close}
shouldCloseOnOverlayClick={shouldCloseOnOverlayClick}
appElement={document.querySelector('#root')}
>
{showClose && close && (
<button type="button" className={classes.close} onClick={close}>
<Icon icon={mdiClose} size={1.5} />
</button>
)}
<div className={classes.content}>{children}</div>
</ReactModal>
);
}
}
export default injectCSS(styles)(Modal);
|