mirror of
https://github.com/penpot/penpot.git
synced 2025-07-29 14:07:14 +02:00
💄 Add shortcut to switch themes
This commit is contained in:
parent
5f0bf84063
commit
abcdc78bed
3 changed files with 34 additions and 3 deletions
|
@ -8,6 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[app.main.data.dashboard :as dd]
|
[app.main.data.dashboard :as dd]
|
||||||
[app.main.data.shortcuts :as ds]
|
[app.main.data.shortcuts :as ds]
|
||||||
|
[app.main.data.workspace :as dw]
|
||||||
[app.main.store :as st]))
|
[app.main.store :as st]))
|
||||||
|
|
||||||
(def shortcuts
|
(def shortcuts
|
||||||
|
@ -29,7 +30,11 @@
|
||||||
:create-new-project {:tooltip "+"
|
:create-new-project {:tooltip "+"
|
||||||
:command "+"
|
:command "+"
|
||||||
:subsections [:general-dashboard]
|
: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]
|
(defn get-tooltip [shortcut]
|
||||||
(assert (contains? shortcuts shortcut) (str shortcut))
|
(assert (contains? shortcuts shortcut) (str shortcut))
|
||||||
|
|
|
@ -603,7 +603,7 @@
|
||||||
(dm/export layout/toggle-layout-flag)
|
(dm/export layout/toggle-layout-flag)
|
||||||
(dm/export layout/remove-layout-flag)
|
(dm/export layout/remove-layout-flag)
|
||||||
|
|
||||||
;; --- Nudge
|
;; --- Profile
|
||||||
|
|
||||||
(defn update-nudge
|
(defn update-nudge
|
||||||
[{:keys [big small] :as params}]
|
[{:keys [big small] :as params}]
|
||||||
|
@ -624,6 +624,26 @@
|
||||||
(let [nudge (get-in state [:profile :props :nudge])]
|
(let [nudge (get-in state [:profile :props :nudge])]
|
||||||
(rx/of (du/update-profile-props {:nudge 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
|
;; --- Set element options mode
|
||||||
|
|
||||||
(dm/export layout/set-options-mode)
|
(dm/export layout/set-options-mode)
|
||||||
|
|
|
@ -546,7 +546,13 @@
|
||||||
;; PREVIEW
|
;; PREVIEW
|
||||||
:preview-frame {:tooltip (ds/meta (ds/alt ds/enter))
|
:preview-frame {:tooltip (ds/meta (ds/alt ds/enter))
|
||||||
:command (ds/c-mod "alt+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
|
(def opacity-shortcuts
|
||||||
(into {} (->>
|
(into {} (->>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue