All files / src/components/Dialog index.jsx

80% Statements 4/5
66.67% Branches 4/6
66.67% Functions 2/3
75% Lines 3/4
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                        8x                       1x                 2x                      
import styles from './style.postcss';
 
import React from 'react';
import pure from 'recompose/pure';
import Modal from 'react-modal';
import classnames from 'classnames';
import PropTypes from 'prop-types';
 
import Card from 'components/Card';
import Icon from 'components/Icon';
import PageLoadingSpinner from 'components/PageLoadingSpinner';
 
export const Dialog = (props) => <Modal className={styles.Dialog}
    overlayClassName={styles.Overlay}
    onRequestClose={(ev) => props.onRequestClose && props.onRequestClose('escape', ev)}
    portalClassName={styles.Portal}
    isOpen={props.isOpen}>
  <Card className={classnames(styles.Dialog_card, props.className)}>
    <Card.Content className={classnames({ [styles.__paddingless]: props.paddingless })}>
      {props.children}
    </Card.Content>
    {
      props.withCloseButton &&
      <div className={styles.Dialog_closeIcon}
          onClick={(ev) => props.onRequestClose && props.onRequestClose('button', ev)}>
        <Icon id="close" />
      </div>
    }
    <PageLoadingSpinner isAbsolutePositioned
        isHidden={! props.isLoading} />
  </Card>
</Modal>;
 
Dialog.propTypes = {
  isOpen: PropTypes.bool.isRequired,
  isLoading: PropTypes.bool,
  withCloseButton: PropTypes.bool,
  onRequestClose: PropTypes.func,  /* called with 'escape' or 'button' arg */
  children: PropTypes.node,
  className: PropTypes.string,
  paddingless: PropTypes.bool,
};
 
export default pure(Dialog);