summaryrefslogtreecommitdiff
path: root/editor/forms
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2021-04-29 15:20:11 +0200
committerSébastien Dailly <sebastien@dailly.me>2022-02-07 16:43:33 +0100
commit2fc4e793b12341df6264e22c0b8bd0f6dd2bd27d (patch)
treeb61b55dc11e4361927c1638d1eb4e82feeef5465 /editor/forms
parenteb319516fd922ab89b7120a885d1e801fa3f45aa (diff)
Added pop-up and events in editor
Diffstat (limited to 'editor/forms')
-rwxr-xr-xeditor/forms/add_page.ml36
-rwxr-xr-xeditor/forms/add_page.mli5
-rwxr-xr-xeditor/forms/delete_page.ml25
-rwxr-xr-xeditor/forms/dune12
-rwxr-xr-xeditor/forms/events.ml5
5 files changed, 83 insertions, 0 deletions
diff --git a/editor/forms/add_page.ml b/editor/forms/add_page.ml
new file mode 100755
index 0000000..597e9d3
--- /dev/null
+++ b/editor/forms/add_page.ml
@@ -0,0 +1,36 @@
+open Brr
+open Brr_note
+open Note
+
+type Events.kind +=
+ | AddPage of { title : Jstr.t }
+
+let create
+ : unit -> Events.t
+ = fun () ->
+
+ (* The element which contains the information *)
+ let input = El.input ()
+ ~at:At.[type' (Jstr.v "text")]
+ in
+
+ let state =
+ S.hold (AddPage { title = Jstr.empty })
+ @@ Evr.on_el
+ (Ev.input)
+ (fun _ ->
+ AddPage { title = El.prop El.Prop.value input }
+ )
+ input in
+
+ ( state
+ , El.div
+ [ El.div ~at:At.[class' (Jstr.v "row")]
+ [ El.div ~at:At.[class' (Jstr.v "col-25")]
+ [ El.label [ El.txt' "Titre"]
+ ~at:[At.for' (Jstr.v "title")]
+ ]
+ ; El.div ~at:At.[class' (Jstr.v "col-75")]
+ [ input ]
+ ]
+ ] )
diff --git a/editor/forms/add_page.mli b/editor/forms/add_page.mli
new file mode 100755
index 0000000..97b1d6c
--- /dev/null
+++ b/editor/forms/add_page.mli
@@ -0,0 +1,5 @@
+type Events.kind +=
+ | AddPage of { title : Jstr.t }
+
+val create
+ : unit -> Events.t
diff --git a/editor/forms/delete_page.ml b/editor/forms/delete_page.ml
new file mode 100755
index 0000000..701162c
--- /dev/null
+++ b/editor/forms/delete_page.ml
@@ -0,0 +1,25 @@
+open Brr
+open Note
+
+type Events.kind +=
+ | DeletePage of Jstr.t [@@unboxed]
+
+let create
+ : Jstr.t -> Events.t
+ = fun name ->
+
+ let state =
+ S.const (DeletePage name) in
+
+ let message = begin
+ let open Jstr in
+
+ (v "La page " )
+ + name
+ + (v " sera définitivement supprimée")
+ end in
+
+ ( state
+ , El.txt message
+ )
+
diff --git a/editor/forms/dune b/editor/forms/dune
new file mode 100755
index 0000000..9876654
--- /dev/null
+++ b/editor/forms/dune
@@ -0,0 +1,12 @@
+(library
+ (name forms)
+ (libraries
+ brr
+ brr.note
+ elements
+ js_lib
+ blog
+ application
+ )
+ (preprocess (pps js_of_ocaml-ppx))
+ )
diff --git a/editor/forms/events.ml b/editor/forms/events.ml
new file mode 100755
index 0000000..339e15d
--- /dev/null
+++ b/editor/forms/events.ml
@@ -0,0 +1,5 @@
+(** This type is designed to be extended for each form *)
+type kind = ..
+
+type t = kind Note.signal * Brr.El.t
+