diff --git a/web/src/components/Dialog.jsx b/web/src/components/Dialog.jsx index 472dc3e92..ad4f57d72 100644 --- a/web/src/components/Dialog.jsx +++ b/web/src/components/Dialog.jsx @@ -1,10 +1,8 @@ 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 }) { +export default function Dialog({ children, portalRootID = 'dialogs' }) { const portalRoot = portalRootID && document.getElementById(portalRootID); const [show, setShow] = useState(false); @@ -27,17 +25,7 @@ export default function Dialog({ actions = [], portalRootID = 'dialogs', title, show ? 'scale-100 opacity-100' : '' }`} > -
- {title} -

{text}

-
-
- {actions.map(({ color, text, onClick, ...props }, i) => ( - - ))} -
+ {children} diff --git a/web/src/components/Prompt.jsx b/web/src/components/Prompt.jsx new file mode 100644 index 000000000..73d0f5e33 --- /dev/null +++ b/web/src/components/Prompt.jsx @@ -0,0 +1,22 @@ +import { h, Fragment } from 'preact'; +import Button from './Button'; +import Heading from './Heading'; +import Dialog from './Dialog'; + +export default function Prompt({ actions = [], title, text }) { +return ( + +
+ {title} +

{text}

+
+
+ {actions.map(({ color, text, onClick, ...props }, i) => ( + + ))} +
+
+) +} diff --git a/web/src/routes/Event.jsx b/web/src/routes/Event.jsx index 48e53e4e9..d24730c09 100644 --- a/web/src/routes/Event.jsx +++ b/web/src/routes/Event.jsx @@ -9,11 +9,11 @@ import Clip from '../icons/Clip'; import Close from '../icons/Close'; import Delete from '../icons/Delete'; import Snapshot from '../icons/Snapshot'; -import Dialog from '../components/Dialog'; import Heading from '../components/Heading'; import VideoPlayer from '../components/VideoPlayer'; import { Table, Thead, Tbody, Th, Tr, Td } from '../components/Table'; import { FetchStatus, useApiHost, useEvent, useDelete } from '../api'; +import Prompt from '../components/Prompt'; const ActionButtonGroup = ({ className, handleClickDelete, close }) => (
@@ -121,7 +121,7 @@ export default function Event({ eventId, close, scrollRef }) {
{showDialog ? ( -