diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2022-12-08 20:39:47 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2022-12-18 18:02:10 +0100 |
commit | 29d463509f9c17a4b5800e99bcef1408e92d744b (patch) | |
tree | 8cb790a9590d847809d3c5d1375f07e84d8f0146 /lib | |
parent | a32f1e426fe8dd73de0e2498838861888b78d776 (diff) |
Update to latest brr
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/elements/input.ml | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/lib/elements/input.ml b/lib/elements/input.ml index 5def7d4..8c4bcea 100755 --- a/lib/elements/input.ml +++ b/lib/elements/input.ml @@ -12,31 +12,27 @@ let slider : at:Brr.At.t list -> Brr.El.t * float S.t = let init_value = Jstr.to_float (El.prop El.Prop.value slider) in let event = - Evr.on_el - Ev.input + Evr.on_el Ev.input (fun _ -> let raw_value = El.prop El.Prop.value slider in - Jstr.to_float raw_value ) + Jstr.to_float raw_value) slider |> S.hold init_value in (slider, event) - -type file = - { file : File.t +type file = { + file : File.t ; content : Jstr.t - } +} (** Read the content from the file *) let file_loader : file Note.E.send -> File.t -> unit = fun event file -> let blob = File.as_blob file in - Fut.await - (Blob.text blob) + Fut.await (Blob.text blob) (Result.iter (fun content -> event { file; content })) - (** Create an imput which load a file. [file_loader (Jstr.v ".json"] will create an input which only accept json @@ -48,8 +44,7 @@ let file_loader : Jstr.t -> Brr.El.t * file Note.event = let add_file_event, add_file_sender = Note.E.create () in let i = - El.input - () + El.input () ~at:[ At.type' (Jstr.v "file"); (At.v (Jstr.v "accept")) selector ] in @@ -59,6 +54,10 @@ let file_loader : Jstr.t -> Brr.El.t * file Note.event = list. *) let on_change files = file_loader add_file_sender (List.hd files) in - Ev.listen Ev.change (fun _e -> on_change (El.Input.files i)) (El.as_target i); + let _ = + Ev.listen Ev.change + (fun _e -> on_change (El.Input.files i)) + (El.as_target i) + in (i, add_file_event) |