import { createRoot } from "react-dom/client"; import React, { useEffect, useRef } from "react"; import { PopupRoot, ModalContainer, ModalContent, ModalHeader, ModalBody, Footer, GetWalletLink, ModalOverlay } from "./styles"; export const present = (render: (close: () => void) => React.ReactNode) => { const div = document.createElement("div"); div.className = "wibe3-popup"; document.body.appendChild(div); const root = createRoot(div); root.render( render(() => { root.unmount(); div.remove(); }) ); }; const Popup = ({ widget, children, header, onClose, style }: { widget?: boolean; children: React.ReactNode; header?: React.ReactNode; onClose: () => void; style?: React.CSSProperties }) => { const containerRef = useRef(null); const contentRef = useRef(null); useEffect(() => { if (widget) return; setTimeout(() => { if (containerRef.current) { containerRef.current.style.opacity = "1"; containerRef.current.style.transform = "translateY(0)"; } if (contentRef.current) { contentRef.current.style.opacity = "1"; contentRef.current.style.transform = "translateY(0)"; } }, 100); }, []); if (widget) { return {children}; } return ( {header && {header}} {children} ); }; export default Popup;