diff --git a/web/modals/modal-overlay.css b/lib/components/modal-overlay.css similarity index 100% rename from web/modals/modal-overlay.css rename to lib/components/modal-overlay.css diff --git a/web/modals/modal-overlay.react.js b/lib/components/modal-overlay.react.js similarity index 100% rename from web/modals/modal-overlay.react.js rename to lib/components/modal-overlay.react.js diff --git a/web/modals/modal.react.js b/web/modals/modal.react.js index 567bef0a5..858fe8656 100644 --- a/web/modals/modal.react.js +++ b/web/modals/modal.react.js @@ -1,78 +1,79 @@ // @flow import classNames from 'classnames'; import * as React from 'react'; +import ModalOverlay from 'lib/components/modal-overlay.react'; + import SWMansionIcon, { type Icon } from '../SWMansionIcon.react'; -import ModalOverlay from './modal-overlay.react'; import css from './modal.css'; export type ModalSize = 'small' | 'large' | 'fit-content'; export type ModalOverridableProps = { +name: string, +icon?: Icon, +onClose: () => void, +withCloseButton?: boolean, +size?: ModalSize, }; type ModalProps = { ...ModalOverridableProps, +children?: React.Node, }; function Modal(props: ModalProps): React.Node { const { size = 'small', children, onClose, name, icon, withCloseButton = true, } = props; const modalContainerClasses = React.useMemo( () => classNames(css.modalContainer, { [css.modalContainerLarge]: size === 'large', [css.modalContainerSmall]: size === 'small', }), [size], ); const cornerCloseButton = React.useMemo(() => { if (!withCloseButton) { return null; } return ( ); }, [onClose, withCloseButton]); const headerIcon = React.useMemo(() => { if (!icon) { return null; } return ; }, [icon]); return ( {headerIcon} {name} {cornerCloseButton} {children} ); } export default Modal;