import React from "react"; import Modal from "react-modal"; import { useThemeUI, Close } from "theme-ui"; import { useSpring, animated, config } from "react-spring"; function StyledModal({ isOpen, onRequestClose, children, allowClose, style, ...props }) { const { theme } = useThemeUI(); const openAnimation = useSpring({ opacity: isOpen ? 1 : 0, transform: isOpen ? "scale(1)" : "scale(0.99)", config: config.default, }); return ( ( {content} )} overlayElement={(props, content) => (
{ // Prevent drag event from triggering with a modal open e.preventDefault(); e.stopPropagation(); }} {...props} > {content}
)} {...props} > {children} {allowClose && ( )}
); } StyledModal.defaultProps = { allowClose: true, style: {}, }; export default StyledModal;