mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 17:21:17 -05: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
|
||||
[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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {} (->>
|
||||
|
|
Loading…
Add table
Reference in a new issue