0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Showing only active sets

This commit is contained in:
Florian Schroedl 2024-08-19 10:46:48 +02:00
parent 8660c372dc
commit 97436531d0
4 changed files with 18 additions and 8 deletions

View file

@ -163,7 +163,8 @@
changes (-> (pcb/empty-changes it)
(pcb/update-token-theme
(wtts/toggle-token-set-to-token-theme token-set-id theme)
theme))]
theme)
(pcb/update-active-token-themes #{(wtts/update-theme-id state)} (wtts/get-active-theme-ids state)))]
(rx/of (dch/commit-changes changes))))))
(defn delete-token-set [token-set-id]

View file

@ -243,9 +243,6 @@
(def workspace-active-theme-ids
(l/derived wtts/get-active-theme-ids st/state))
(def workspace-active-theme-id
(l/derived wtts/update-theme-id st/state))
(def workspace-token-themes
(l/derived wtts/get-workspace-themes-index st/state))

View file

@ -28,7 +28,8 @@
[cuerdas.core :as str]
[okulary.core :as l]
[rumext.v2 :as mf]
[shadow.resource]))
[shadow.resource]
[clojure.set :as set]))
(def lens:token-type-open-status
(l/derived (l/in [:workspace-tokens :open-status]) st/state))
@ -168,10 +169,14 @@
(mf/defc token-sets
[_props]
(let [active-theme-ids (mf/deref refs/workspace-active-theme-ids)
selected-theme-id (mf/deref refs/workspace-active-theme-id)
themes (mf/deref refs/workspace-ordered-token-themes)
themes-index (mf/deref refs/workspace-token-themes)
selected-theme (get themes-index selected-theme-id)
active-set-ids (reduce
(fn [acc cur]
(if-let [sets (get-in themes-index [cur :sets])]
(set/union acc sets)
acc))
#{} active-theme-ids)
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)
token-sets (mf/deref refs/workspace-token-sets)]
[:div
@ -234,7 +239,7 @@
(dom/prevent-default e)
(dom/stop-propagation e)
(st/emit! (wdt/toggle-token-set id)))}
(when (wtts/token-set-enabled-in-theme? id selected-theme) "👁️")]
(when (get active-set-ids id) "👁️")]
[:button {:on-click (fn [e]
(dom/prevent-default e)
(dom/stop-propagation e)

View file

@ -59,6 +59,13 @@
(or temp-theme-id-set #{})
new-themes)))
(defn get-active-theme-ids-or-temp-theme-id
[state]
(let [active-theme-ids (get-active-theme-ids state)]
(if (seq active-theme-ids)
active-theme-ids
(get-temp-theme-id state))))
(defn update-theme-id
[state]
(let [active-themes (get-active-theme-ids state)