From 2fc4e793b12341df6264e22c0b8bd0f6dd2bd27d Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 29 Apr 2021 15:20:11 +0200 Subject: Added pop-up and events in editor --- editor/forms/add_page.ml | 36 ++++++++++++++++++++++++++++++++++++ editor/forms/add_page.mli | 5 +++++ editor/forms/delete_page.ml | 25 +++++++++++++++++++++++++ editor/forms/dune | 12 ++++++++++++ editor/forms/events.ml | 5 +++++ 5 files changed, 83 insertions(+) create mode 100755 editor/forms/add_page.ml create mode 100755 editor/forms/add_page.mli create mode 100755 editor/forms/delete_page.ml create mode 100755 editor/forms/dune create mode 100755 editor/forms/events.ml (limited to 'editor/forms') 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 + -- cgit v1.2.3