diff options
Diffstat (limited to 'src/View/Modal.ml')
-rw-r--r-- | src/View/Modal.ml | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/View/Modal.ml b/src/View/Modal.ml new file mode 100644 index 0000000..9365555 --- /dev/null +++ b/src/View/Modal.ml @@ -0,0 +1,27 @@ +let hide () = + let body = Document.querySelectorUnsafe "body" in + let modal = Document.querySelectorUnsafe ".g-Modal" in + Element.removeChild body modal + +let show content = + let body = Document.querySelectorUnsafe "body" in + let view = + H.div + [| HA.class_ "g-Modal" |] + [| H.div + [| HA.class_ "g-Modal__Curtain" + ; HE.on_click (fun _ -> hide ()) + |] + [| |] + ; H.div + [| HA.class_ "g-Modal__Window" |] + [| H.button + [| HA.class_ "g-Modal__Close" + ; HE.on_click (fun _ -> hide ()) + |] + [| H.text "X" |] + ; content + |] + |] + in + Element.appendChild body view |