summaryrefslogtreecommitdiff
path: root/blog
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2020-12-23 19:11:31 +0100
committerSébastien Dailly <sebastien@chimrod.com>2020-12-23 19:11:31 +0100
commitec812521b31471ce9ac3d9bdf1288b1569defbc8 (patch)
treed384c959b9e9bb2a04141ab56077026fe6e7c7f3 /blog
parent6354358caa1dfbf2fe1d481f6ac5fba3775938fc (diff)
Add svg output
Diffstat (limited to 'blog')
-rwxr-xr-xblog/dune4
-rwxr-xr-xblog/sidebar.ml54
2 files changed, 22 insertions, 36 deletions
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