import React, { ReactNode } from 'react'; import cx from 'classnames'; interface Props { children?: ReactNode; isOpened?: boolean; onClose?: () => void; onOverlay?: () => void; centered?: boolean; extraClass?: string; contentExtraClass?: string; footer?: string | ReactNode; header?: string | ReactNode; withGradient?: boolean; withMobile?: boolean; } const Modal = React.forwardRef((props, ref) => { const { children, isOpened = false, onClose, centered = false, header, withMobile = false, footer = null, extraClass = '', contentExtraClass = '', onOverlay, withGradient } = props; const className = cx( 'c-modal', 'u-align--center', extraClass, { 'c-modal--opened': isOpened }, { 'c-modal--centered': centered }, { 'c-modal--with-mobile': withMobile }, ); const overlayClassName = cx('c-overlay', 'js-overlay-hit-area', { 'c-overlay--opened': isOpened }); const contentClassNames = cx('c-modal__content', contentExtraClass); const footerClassName = cx('c-modal__footer', { 'c-modal__footer--gradient': withGradient }); return ( <> {onOverlay &&
onOverlay()} />}
{onClose &&
onClose()} />}
{header}
{children}
{withGradient &&
}
{footer &&
{footer}
}
); }); export { Modal };