mirror of
https://github.com/penpot/penpot.git
synced 2025-07-31 18:38:31 +02:00
Add active theme toggling
This commit is contained in:
parent
f0e0e9334e
commit
9a745ea8bc
7 changed files with 46 additions and 5 deletions
|
@ -118,6 +118,16 @@
|
|||
theme))
|
||||
:else changes)))
|
||||
|
||||
(defn toggle-token-theme [token-theme-id]
|
||||
(ptk/reify ::toggle-token-theme
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
(let [themes (wtts/get-active-theme-ids state)
|
||||
new-themes (wtts/toggle-active-theme-id token-theme-id state)
|
||||
changes (-> (pcb/empty-changes it)
|
||||
(pcb/update-active-token-themes new-themes themes))]
|
||||
(rx/of (dch/commit-changes changes))))))
|
||||
|
||||
(defn create-token-set [token-set]
|
||||
(let [new-token-set (merge
|
||||
{:id (uuid/next)
|
||||
|
|
|
@ -208,8 +208,9 @@
|
|||
[:button
|
||||
{:on-click (fn [e]
|
||||
(dom/prevent-default e)
|
||||
(dom/stop-propagation e))}
|
||||
(if (some-> active-theme-ids (get id)) "✅" "❎")]
|
||||
(dom/stop-propagation e)
|
||||
(st/emit! (wdt/toggle-token-theme id)))}
|
||||
(if (get active-theme-ids id) "✅" "❎")]
|
||||
[:button {:on-click (fn [e]
|
||||
(dom/prevent-default e)
|
||||
(dom/stop-propagation e)
|
||||
|
|
|
@ -18,11 +18,22 @@
|
|||
(group-by :group))))
|
||||
|
||||
(defn get-active-theme-ids [state]
|
||||
(get-in state [:workspace-data :token-active-themes]))
|
||||
(get-in state [:workspace-data :token-active-themes] #{}))
|
||||
|
||||
(defn get-temp-theme-id [state]
|
||||
(get-in state [:workspace-data :token-theme-temporary-id]))
|
||||
|
||||
(defn toggle-active-theme-id [theme-id state]
|
||||
(let [temp-theme-id (get-temp-theme-id state)
|
||||
themes (get-active-theme-ids state)
|
||||
theme-without-temp (disj themes temp-theme-id)
|
||||
new-themes (if (get theme-without-temp theme-id)
|
||||
(disj theme-without-temp theme-id)
|
||||
(conj theme-without-temp theme-id))]
|
||||
(if (empty? new-themes)
|
||||
#{temp-theme-id}
|
||||
new-themes)))
|
||||
|
||||
(defn update-theme-id
|
||||
[state]
|
||||
(let [active-themes (get-active-theme-ids state)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue