All files / components/ui/Modal Modal.tsx

70% Statements 7/10
66.66% Branches 4/6
33.33% Functions 1/3
70% Lines 7/10

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    1x 1x                             1x               1x 17x                                                   1x     1x  
 
import React, {FC} from 'react';
import styles from './Modal.module.scss';
import cn from 'clsx';
 
interface Props {
    isShow: {
        show: boolean,
        animate: boolean
    },
    type?: 'compact',
    side?: 'right',
    content: React.ReactElement,
    footer: React.ReactElement,
    classNames?: string,
    setClose: () => void
}
 
const closeModalAction = (setModal: any) => {
    setModal({ show: true, animate: false });
 
    setTimeout(() => {
        setModal({ show: false, animate: false });
    }, 310);
}
 
const Modal: FC<Props> = ({ isShow, type, content, footer, classNames, setClose }) => {
    return (
        <div className={cn(styles.modal, isShow.show && styles[`is-active`], isShow.animate && styles[`is-animate`], styles[`modal-${type}`], classNames)}>
            <div className={styles.modal__overlay} data-dismiss="modal" onClick={setClose}></div>
            <div className={styles.modal__wrap}>
                <div className={styles.modal__window}>
                    <div className={styles.modal__content}>
                        <div className={styles.modal__body} data-modal={'modal-body'}>
                            <div className={styles.modal__container}>
                                { content }
                            </div>
                        </div>
                        {footer &&
                            <div className={styles.modal__footer} data-modal={'modal-footer'}>
                                <div className={styles.modal__container}>
                                    { footer }
                                </div>
                            </div>
                        }
                    </div>
                </div>
            </div>
        </div>
    );
};
 
export {
    closeModalAction
}
 
export default Modal;