import { h, Fragment } from 'preact'; import Button from './Button'; import Heading from './Heading'; import { createPortal } from 'preact/compat'; import { useState, useEffect } from 'preact/hooks'; export default function Dialog({ actions = [], portalRootID = 'dialogs', title, text }) { const portalRoot = portalRootID && document.getElementById(portalRootID); const [show, setShow] = useState(false); useEffect(() => { window.requestAnimationFrame(() => { setShow(true); }); }, []); const dialog = (
{title}

{text}

{actions.map(({ color, text, onClick, ...props }, i) => ( ))}
); return portalRoot ? createPortal(dialog, portalRoot) : dialog; }