All files modals.tsx

100% Statements 28/28
100% Branches 2/2
100% Functions 6/6
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 9619x 19x 19x           19x   1x     1x             1x                               19x   3x 3x 3x 3x     3x                   19x   2x 2x 2x     2x             19x   2x 2x 2x     2x             19x   2x 2x 2x     2x            
import * as classNames from 'classnames';
import * as React from 'react';
import * as CSSTransitionGroup from 'react-transition-group/CSSTransitionGroup';
 
export interface IModalRendererProps {
  modals: React.ReactNode[];
}
 
export const ModalRenderer: React.SFC<IModalRendererProps & React.HTMLProps<HTMLDivElement>> = (props) => {
  const {
    modals,
  } = props;
 
  return (
    <CSSTransitionGroup
      transitionName="modal-transition"
      transitionEnterTimeout={300}
      transitionLeaveTimeout={200}
    >
      {
        modals && modals.map((modal, index) => (
          <div key={index} className="modal-container">
            <div className="modal-position">
              {modal}
            </div>
          </div>
        ))
      }
    </CSSTransitionGroup>
  );
}
 
export interface IModalProps {
  onClickOutside(event: React.MouseEvent<HTMLDivElement>): void;
}
 
export const Modal: React.SFC<IModalProps & React.HTMLProps<HTMLDivElement>> = (props) => {
  const {
    className,
    children,
    onClickOutside,
    ...remainingProps
  } = props;
 
  return (
    <div>
      <div className="modal-overlay" onClick={onClickOutside} />
      <div {...remainingProps} className={classNames('modal', className)}>
        {children}
      </div>
    </div>
  );
}
 
export const ModalHeader: React.SFC<React.HTMLProps<HTMLDivElement>> = (props) => {
  const {
    className,
    children,
    ...remainingProps
  } = props;
 
  return (
    <div {...remainingProps} className={classNames('modal-header', className)}>
      {children}
    </div>
  );
}
 
export const ModalFooter: React.SFC<React.HTMLProps<HTMLDivElement>> = (props) => {
  const {
    className,
    children,
    ...remainingProps
  } = props;
 
  return (
    <div {...remainingProps} className={classNames('modal-footer', className)}>
      {children}
    </div>
  );
}
 
export const ModalCloseIcon: React.SFC<React.HTMLProps<HTMLDivElement>> = (props) => {
  const {
    className,
    children,
    ...remainingProps
  } = props;
 
  return (
    <div {...remainingProps} className={classNames('modal-close-icon', className)}>
      {children}
    </div>
  );
}