summaryrefslogtreecommitdiff
path: root/lib/elements
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2022-02-07 15:17:33 +0100
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:22:43 +0100
commitefd7e6c313b7a807af3d10b792d6f22dc1b6958c (patch)
treee3dc8954f21216d5f39f2a51f0ac7d6044fdff22 /lib/elements
parent56a215bb448870b48befd78668d7bb39e0530f51 (diff)
Update popup
Diffstat (limited to 'lib/elements')
-rwxr-xr-xlib/elements/popup.ml22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/elements/popup.ml b/lib/elements/popup.ml
index e2e2a76..bf97559 100755
--- a/lib/elements/popup.ml
+++ b/lib/elements/popup.ml
@@ -2,9 +2,13 @@ open Brr
open Brr_note
module Js = Js_of_ocaml.Js
-let create
- : ?form:('a Note.signal * El.t) option -> title:Jstr.t -> 'a option Note.event
- = fun ?(form = None) ~title ->
+let create:
+ ?form:('a Note.signal * El.t)
+ -> ?valid_on:(bool Note.signal)
+ -> title:Jstr.t
+ -> unit
+ -> 'a option Note.event
+ = fun ?form ?valid_on ~title () ->
(* Ensure we keep a track for the signal event.
@@ -22,6 +26,18 @@ let create
and submit_btn = El.input ()
~at:At.[type' (Jstr.v "submit")] in
+ begin match valid_on with
+ | None -> ()
+ | Some s ->
+ Elr.def_at
+ (Jstr.v "disabled")
+ (Note.S.map
+ (fun value -> if (not value) then Some (Jstr.empty) else None)
+ s)
+ submit_btn
+ end;
+
+
let container = match form with
| None -> El.div
| Some _ -> El.form