From 363936641a31b0b508197d41bea1ce116931b5d4 Mon Sep 17 00:00:00 2001 From: Paweł Bernaciak Date: Sat, 20 Jan 2024 11:03:44 +0100 Subject: New element creator --- frontend/src/components/Dialog.tsx | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 frontend/src/components/Dialog.tsx (limited to 'frontend/src/components/Dialog.tsx') diff --git a/frontend/src/components/Dialog.tsx b/frontend/src/components/Dialog.tsx new file mode 100644 index 0000000..4fa6bf7 --- /dev/null +++ b/frontend/src/components/Dialog.tsx @@ -0,0 +1,54 @@ +import { FC, PropsWithChildren, useEffect, useRef } from 'react'; + +interface DialogProps { + visible: boolean; + closeDialog: () => void; +} + +const Dialog: FC> = ({ + visible, + closeDialog, + children, +}) => { + const dialogRef = useRef(null); + + useEffect(() => { + if (visible) { + dialogRef.current?.showModal(); + } else { + dialogRef.current?.close(); + } + }, [visible]); + + const handleButtonClick = (e: React.MouseEvent) => { + e.preventDefault(); + closeDialog(); + }; + + return ( + +
+
+ +
+ {children} +
+
+ ); +}; + +export default Dialog; -- cgit v1.2.3