From ec812521b31471ce9ac3d9bdf1288b1569defbc8 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Wed, 23 Dec 2020 19:11:31 +0100 Subject: Add svg output --- blog/dune | 4 ++-- blog/sidebar.ml | 54 ++++++++++++++++++++---------------------------------- 2 files changed, 22 insertions(+), 36 deletions(-) (limited to 'blog') diff --git a/blog/dune b/blog/dune index 532a7ee..43b14ed 100755 --- a/blog/dune +++ b/blog/dune @@ -3,6 +3,6 @@ (libraries brr brr.note - js_of_ocaml-tyxml) - (preprocess (pps tyxml-ppx)) + elements + ) ) diff --git a/blog/sidebar.ml b/blog/sidebar.ml index ed4b856..83afb13 100755 --- a/blog/sidebar.ml +++ b/blog/sidebar.ml @@ -24,21 +24,6 @@ let rec clean clean el ) -(** Create a slider element, and the event on change *) -let slider ~at = - let slider = - El.input ~at () in - - let event = - Evr.on_el - Ev.input - (fun _ -> - let raw_value = El.prop El.Prop.value slider in - Jstr.to_int raw_value) - slider - in - slider, event - let click_event el = Evr.on_el Ev.click @@ -51,7 +36,7 @@ let show_value = function El.txt (Jstr.of_int input) let add_button - : El.t -> unit E.t + : El.t -> unit E.t * unit E.t = fun element -> let open El in @@ -73,10 +58,11 @@ let add_button ; class' (Jstr.v "fa-download") ] [] ; txt' "Download"] in + let export_event = click_event export in let nib_size, value = - slider + Elements.Input.slider ~at:At.[ type' (Jstr.v "range") ; v (Jstr.v "min") (Jstr.v "0") ; v (Jstr.v "max") (Jstr.v "50") @@ -84,30 +70,30 @@ let add_button ] in let width = El.div [] in - Elr.set_children + Elr.def_children width - ~on:(value - |> E.map (fun v -> - [ txt' "Width : " - ; show_value v ] - ) - ); + (value + |> S.map (fun v -> + [ txt' "Width : " + ; show_value v ] + ) + ); let input_angle, angle_event = - slider + Elements.Input.slider ~at:At.[ type' (Jstr.v "range") ; v (Jstr.v "min") (Jstr.v "0") ; v (Jstr.v "max") (Jstr.v "90")] in let angle = El.div [] in - Elr.set_children + Elr.def_children angle - ~on:(angle_event - |> E.map (fun v -> - [ txt' "Angle : " - ; show_value v - ; txt' "°" ] - ) - ); + (angle_event + |> S.map (fun v -> + [ txt' "Angle : " + ; show_value v + ; txt' "°" ] + ) + ); let click = Evr.on_el Ev.click Evr.unit delete in let _ = click in @@ -128,4 +114,4 @@ let add_button ] in - delete_event + delete_event, export_event -- cgit v1.2.3