blob: 83afb13ab434898538dbab02ed16dacd297f1af0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
open StdLabels
open Brr
open Brr_note
open Note
(** Return the sidebar *)
let get
: unit -> El.t option
= fun () ->
List.find_opt (El.children @@ Document.body G.document)
~f:(fun t -> El.has_tag_name El.Name.aside t)
let rec clean
: El.t -> unit
= fun el ->
List.iter (El.children el)
~f:(fun el ->
(* Remove the links from the sidebar, keep h1 and other stuff *)
if (El.has_tag_name (Jstr.v "nav") el)
|| (El.has_tag_name (Jstr.v "ul") el) then
El.remove el
else
clean el
)
let click_event el =
Evr.on_el
Ev.click
Evr.unit
el
let show_value = function
| None -> El.txt' ""
| Some input ->
El.txt (Jstr.of_int input)
let add_button
: El.t -> unit E.t * unit E.t
= fun element ->
let open El in
let delete =
button
[ El.i
~at:At.[ class' (Jstr.v "fas")
; class' (Jstr.v "fa-times-circle") ]
[]
; txt' "Delete "] in
let delete_event = click_event delete in
let export =
button
[ El.i
~at:At.[ class' (Jstr.v "fas")
; class' (Jstr.v "fa-download") ]
[]
; txt' "Download"] in
let export_event = click_event export in
let nib_size, value =
Elements.Input.slider
~at:At.[ type' (Jstr.v "range")
; v (Jstr.v "min") (Jstr.v "0")
; v (Jstr.v "max") (Jstr.v "50")
; id (Jstr.v "nib_size")
] in
let width = El.div [] in
Elr.def_children
width
(value
|> S.map (fun v ->
[ txt' "Width : "
; show_value v ]
)
);
let input_angle, angle_event =
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.def_children
angle
(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
let () =
El.append_children element
[ hr ()
; delete
; export
; hr ()
; width
; nib_size
; El.br ()
; angle
; input_angle
]
in
delete_event, export_event
|