diff --git a/frontend/src/app/main/data/dashboard/shortcuts.cljs b/frontend/src/app/main/data/dashboard/shortcuts.cljs index 54140e6502..4baa33966a 100644 --- a/frontend/src/app/main/data/dashboard/shortcuts.cljs +++ b/frontend/src/app/main/data/dashboard/shortcuts.cljs @@ -8,6 +8,7 @@ (:require [app.main.data.dashboard :as dd] [app.main.data.shortcuts :as ds] + [app.main.data.workspace :as dw] [app.main.store :as st])) (def shortcuts @@ -29,7 +30,11 @@ :create-new-project {:tooltip "+" :command "+" :subsections [:general-dashboard] - :fn #(st/emit! (dd/create-element))}}) + :fn #(st/emit! (dd/create-element))} + + :toggle-light-dark {:tooltip (ds/meta (ds/alt "Q")) + :command (ds/c-mod "alt+q") + :fn #(st/emit! (dw/toggle-theme))}}) (defn get-tooltip [shortcut] (assert (contains? shortcuts shortcut) (str shortcut)) diff --git a/frontend/src/app/main/data/workspace.cljs b/frontend/src/app/main/data/workspace.cljs index 9255f9bd75..a4730c09d6 100644 --- a/frontend/src/app/main/data/workspace.cljs +++ b/frontend/src/app/main/data/workspace.cljs @@ -603,7 +603,7 @@ (dm/export layout/toggle-layout-flag) (dm/export layout/remove-layout-flag) -;; --- Nudge +;; --- Profile (defn update-nudge [{:keys [big small] :as params}] @@ -624,6 +624,26 @@ (let [nudge (get-in state [:profile :props :nudge])] (rx/of (du/update-profile-props {:nudge nudge})))))) +(defn toggle-theme + [] + (ptk/reify ::toggle-theme + ptk/UpdateEvent + (update [_ state] + (update-in + state + [:profile :theme] + (fn [theme] + (cond + (= theme "default") + "light" + + :else + "default")))) + + ptk/WatchEvent + (watch [_ state _] + (rx/of (du/update-profile (:profile state)))))) + ;; --- Set element options mode (dm/export layout/set-options-mode) diff --git a/frontend/src/app/main/data/workspace/shortcuts.cljs b/frontend/src/app/main/data/workspace/shortcuts.cljs index f43223278d..abac1ae186 100644 --- a/frontend/src/app/main/data/workspace/shortcuts.cljs +++ b/frontend/src/app/main/data/workspace/shortcuts.cljs @@ -546,7 +546,13 @@ ;; PREVIEW :preview-frame {:tooltip (ds/meta (ds/alt ds/enter)) :command (ds/c-mod "alt+enter") - :fn #(emit-when-no-readonly (dp/open-preview-selected))}}) + :fn #(emit-when-no-readonly (dp/open-preview-selected))} + + + ;; THEME + :toggle-light-dark {:tooltip (ds/meta (ds/alt "Q")) + :command (ds/c-mod "alt+q") + :fn #(st/emit! (dw/toggle-theme))}}) (def opacity-shortcuts (into {} (->>