import React, { ForwardedRef, forwardRef } from 'react' import { ModalStyle, ModalBaseStyle, ModalHeaderStyle, ModalTitleStyle, ModalTitleIconStyle, ModalTitleTextStyle, ModalCloseStyle, ModalContentStyle, ModalBackStyle, ModalSubtitleStyle, } from './ModalStyles' import { ModalProps } from './types' import ModalOverlay from './ModalOverlay' function Modal(props: ModalProps, ref?: ForwardedRef) { const { children, title, titleIcon, subtitle, center = false, extra, open, ...rest } = props const { onClose, onBack } = props const withTitleIcon = !!titleIcon const withSubtitle = !!subtitle const withCloseButton = !!onClose const withBackButton = !!onBack const modalHeader = ( {withBackButton && } {withTitleIcon && ( {titleIcon} )} {title} {withCloseButton && } ) return ( {modalHeader} {withSubtitle && {subtitle}} {children} {extra} ) } export default forwardRef(Modal)