import React from 'react' import PropTypes from 'prop-types' import { motion, AnimatePresence } from "framer-motion" import { RemoveScroll } from 'react-remove-scroll' import useKeypress from '../hooks/useKeypress'; export const Popup = (props) => { const { opened, title, close, children } = props const popupMotionVariants = { hidden: { opacity: 0, scaleY: 0, transition: { type: "linear", duration: .3 } }, visible: { opacity: 1, scaleY: 1, transition: { type: "spring", damping: 50, stiffness: 50000, } }, } useKeypress('Escape', () => { opened && close && close() }); return <> {opened &&
e.stopPropagation()}>
{title}
{children}
}
} export default Popup; Popup.propTypes = { opened: PropTypes.bool, title: PropTypes.string, close: PropTypes.func, children: PropTypes.element, }