summaryrefslogtreecommitdiff
path: root/src/components/Modal.tsx
blob: e91523cb315fe619a19e29596c6d06f90758b342 (plain)
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
import cx from 'clsx';
import * as React from 'react';
import Modal, { Props as ReactModalProps } from 'react-modal';

import s0 from './Modal.module.scss';

type Props = ReactModalProps & {
  isOpen: boolean;
  onRequestClose: (...args: any[]) => any;
  children: React.ReactNode;
  className?: string;
  overlayClassName?: string;
};

function ModalAPIConfig({
  isOpen,
  onRequestClose,
  className,
  overlayClassName,
  children,
  ...otherProps
}: Props) {
  const contentCls = cx(className, s0.content);
  const overlayCls = cx(overlayClassName, s0.overlay);
  return (
    <Modal
      isOpen={isOpen}
      onRequestClose={onRequestClose}
      className={contentCls}
      overlayClassName={overlayCls}
      {...otherProps}
    >
      {children}
    </Modal>
  );
}

export default React.memo(ModalAPIConfig);