blob: 15326a2897c170dfb97da0af76cfc0139511e8e4 (
plain) (
blame)
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
|
import { mdiClose } from '@mdi/js';
import classnames from 'classnames';
import { Component, type ReactNode } from 'react';
import injectCSS, { type WithStylesProps } from 'react-jss';
import ReactModal from 'react-modal';
import Icon from '../icon';
import styles from './styles';
interface IProps extends WithStylesProps<typeof styles> {
children: ReactNode;
isOpen: boolean;
close: () => void;
className?: string | null;
portal?: string;
shouldCloseOnOverlayClick?: boolean;
showClose?: boolean;
}
class Modal extends Component<IProps> {
render() {
const {
children,
classes,
isOpen,
close,
className = null,
portal = 'modal-portal',
shouldCloseOnOverlayClick = false,
showClose = true,
} = 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);
|