From a6e30a95b5dcd34fb9e65d9a26f0844ec75bb004 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 3 Jun 2021 11:41:28 +0200 Subject: Greyed the delete button on main page --- editor/actions/editor_actions.ml | 23 +++++++++++++++-------- editor/actions/editor_actions.mli | 2 +- editor/editor.css | 11 +++++------ editor/editor.ml | 11 ++--------- 4 files changed, 23 insertions(+), 24 deletions(-) diff --git a/editor/actions/editor_actions.ml b/editor/actions/editor_actions.ml index 0053890..5b2a3d3 100755 --- a/editor/actions/editor_actions.ml +++ b/editor/actions/editor_actions.ml @@ -13,6 +13,7 @@ type t = ; childs : El.t list ; ul : El.t ; mutable completed : bool + ; delete_button : El.t } let build @@ -153,6 +154,7 @@ let build { ev = result_event ; childs ; ul + ; delete_button ; completed = false } @@ -175,23 +177,28 @@ let get_notes _ = [ El.txt name ] ]) let complete - : t -> State.t Note.event -> El.t list - = fun ({ childs; ul ; completed ; _ } as t) change -> + : t -> State.t Note.signal -> El.t list + = fun ({ childs; ul ; completed ; delete_button ; _ } as t) change -> let () = if completed then raise (Failure "The action panel is already registered") in let note_list = - Note.E.map get_notes + Note.S.map get_notes change in t.completed <- true; - (* Register all the notes at the creation time *) - El.set_children ul (get_notes ()); - - (* Then register updates *) - Elr.set_children ul ~on:note_list; + Elr.def_children ul note_list; + Elr.def_at + (Jstr.v "disabled") + (Note.S.map + (fun state -> + match state.State.page_id with + | None -> Some Jstr.empty + | Some _ -> None) + change) + delete_button; childs diff --git a/editor/actions/editor_actions.mli b/editor/actions/editor_actions.mli index 48d5676..27b09d7 100755 --- a/editor/actions/editor_actions.mli +++ b/editor/actions/editor_actions.mli @@ -14,4 +14,4 @@ val get_event *) val complete - : t -> State.t Note.event -> Brr.El.t list + : t -> State.t Note.signal -> Brr.El.t list diff --git a/editor/editor.css b/editor/editor.css index fde771d..d3700c2 100644 --- a/editor/editor.css +++ b/editor/editor.css @@ -447,16 +447,15 @@ footnote::after { border: 0px } -.action-button.active { - background-color: white; - color: #333; - border-radius: 5px; +.action-button:disabled { + color: grey; } -.action-button:hover { +.action-button:enabled:hover { border-bottom: 1px solid white; } -.action-button:active { + +.action-button:enabled:active { transform: translateY(1px); } diff --git a/editor/editor.ml b/editor/editor.ml index f27c60c..9eee49e 100755 --- a/editor/editor.ml +++ b/editor/editor.ml @@ -153,16 +153,9 @@ let app id content = ]) in - let change_event = - Note.S.changes app_state in - - let childs = Editor_actions.complete side_elements change_event in + let childs = Editor_actions.complete side_elements app_state in let () = El.append_children sidebar childs in - let _ = - Note.E.log change_event - (fun _ -> ()) - |> Option.iter Note.Logr.hold - in + let _ = Note.(Logr.hold (S.log app_state (fun _ -> ()))) in () | _ -> -- cgit v1.2.3