diff --git a/ui/src/Modal.tsx b/ui/src/Modal.tsx new file mode 100644 index 0000000..041a13e --- /dev/null +++ b/ui/src/Modal.tsx @@ -0,0 +1,39 @@ +import {useEffect, useRef} from "react"; + +export function Modal(props: { + isOpen: boolean; + setClosed: () => void; + children: any; +}){ + + const ref = useRef(); + useEffect(() => { + if(props.isOpen){ + // @ts-ignore + ref.current.showModal(); + } else { + // @ts-ignore + ref.current.close(); + } + }, [props.isOpen]) + + + return( + // The style part is just to make sure the dialog is hidden the split second before useEffect runs, + // in case the dialog content is derived from whatever determines isOpen + +
+ +
+
+ {props.children} +
+
+ ); + +} \ No newline at end of file diff --git a/ui/src/style.less b/ui/src/style.less index d34f7df..a205905 100644 --- a/ui/src/style.less +++ b/ui/src/style.less @@ -163,4 +163,29 @@ margin-left: 10px; margin-right: 10px; } +} + +dialog { + border-radius: 10px; + z-index: 1; + + + .close-button-div { + display: flex; + justify-content: end; + + button { + border: 0; + background-color: inherit; + font-size: 1.5rem; + color: #aaaaaa; + font-weight: bold; + + &:hover { + color: black; + cursor: pointer; + } + } + } + } \ No newline at end of file