PageModal.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import ReactModal from 'react-modal';
  2. import {FC, PropsWithChildren} from 'react';
  3. import {CloseOutlined} from '@ant-design/icons';
  4. const styles: ReactModal.Styles = {
  5. content: {
  6. width: '90vw',
  7. height: '90vh',
  8. position: 'relative',
  9. overflow: 'hidden',
  10. },
  11. };
  12. type Props = {
  13. visible: boolean;
  14. onClose: () => void;
  15. 'data-testid'?: string;
  16. };
  17. const LDPageModal: FC<PropsWithChildren<Props>> = function(props) {
  18. const {
  19. children,
  20. visible,
  21. onClose,
  22. } = props;
  23. return (
  24. <ReactModal
  25. shouldCloseOnOverlayClick
  26. onRequestClose={onClose}
  27. isOpen={visible}
  28. ariaHideApp={false}
  29. style={styles}
  30. closeTimeoutMS={200}
  31. >
  32. <section className="ld-page-dialog" data-testid={props['data-testid']}>
  33. <div className="ld-page-dialog-close">
  34. <CloseOutlined
  35. className="ld-page-dialog-close-icon"
  36. onClick={onClose}
  37. />
  38. </div>
  39. <div className="ld-page-dialog-content">{children}</div>
  40. </section>
  41. </ReactModal>
  42. );
  43. };
  44. export default LDPageModal;