mirror of
https://github.com/blakeblackshear/frigate.git
synced 2025-09-28 17:53:51 +02:00
* fixed position for Dialog * added eventId to deleted item * removed page route redirect + New Close Button * event component added to events list. New delete reducer * removed event route * moved delete reducer to event page * removed redundant event details * keep aspect ratio * keep aspect ratio * removed old buttons - repositioned to top * removed console.log * event view function * removed clip header * top position * centered image if no clips avail * comments * linting * lint * added scrollIntoView when event has been mounted * added Clip header * added scrollIntoView to test * lint * useRef to scroll event into view * removed unused functions * reverted changes to event.test * scroll into view * moved delete reducer * removed commented code * styling * moved close button to right side * Added new close svg icon Co-authored-by: Bernt Christian Egeland <cbegelan@gmail.com>
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
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 = (
|
|
<Fragment>
|
|
<div
|
|
data-testid="scrim"
|
|
key="scrim"
|
|
className="fixed bg-fixed inset-0 z-10 flex justify-center items-center bg-black bg-opacity-40"
|
|
>
|
|
<div
|
|
role="modal"
|
|
className={`absolute rounded shadow-2xl bg-white dark:bg-gray-700 max-w-sm text-gray-900 dark:text-white transition-transform transition-opacity duration-75 transform scale-90 opacity-0 ${
|
|
show ? 'scale-100 opacity-100' : ''
|
|
}`}
|
|
>
|
|
<div className="p-4">
|
|
<Heading size="lg">{title}</Heading>
|
|
<p>{text}</p>
|
|
</div>
|
|
<div className="p-2 flex justify-start flex-row-reverse space-x-2">
|
|
{actions.map(({ color, text, onClick, ...props }, i) => (
|
|
<Button className="ml-2" color={color} key={i} onClick={onClick} type="text" {...props}>
|
|
{text}
|
|
</Button>
|
|
))}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</Fragment>
|
|
);
|
|
|
|
return portalRoot ? createPortal(dialog, portalRoot) : dialog;
|
|
}
|