import { AnimatePresence, motion } from "motion/react";
import usePopupStore from "../store/popupStore";

function PopupContainer() {
  const { popup, position } = usePopupStore();

  return (
    <AnimatePresence>
      {popup && (
        <motion.div
          className="absolute"
          initial={{ opacity: 0 }}
          animate={{ opacity: 1 }}
          exit={{ opacity: 0 }}
          style={{ top: position.y, left: position.x }}
        >
          {popup}
        </motion.div>
      )}
    </AnimatePresence>
  );
}

export default PopupContainer;
