mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Showing only active sets
This commit is contained in:
parent
8660c372dc
commit
97436531d0
4 changed files with 18 additions and 8 deletions
|
@ -163,7 +163,8 @@
|
||||||
changes (-> (pcb/empty-changes it)
|
changes (-> (pcb/empty-changes it)
|
||||||
(pcb/update-token-theme
|
(pcb/update-token-theme
|
||||||
(wtts/toggle-token-set-to-token-theme token-set-id 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))))))
|
(rx/of (dch/commit-changes changes))))))
|
||||||
|
|
||||||
(defn delete-token-set [token-set-id]
|
(defn delete-token-set [token-set-id]
|
||||||
|
|
|
@ -243,9 +243,6 @@
|
||||||
(def workspace-active-theme-ids
|
(def workspace-active-theme-ids
|
||||||
(l/derived wtts/get-active-theme-ids st/state))
|
(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
|
(def workspace-token-themes
|
||||||
(l/derived wtts/get-workspace-themes-index st/state))
|
(l/derived wtts/get-workspace-themes-index st/state))
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[okulary.core :as l]
|
[okulary.core :as l]
|
||||||
[rumext.v2 :as mf]
|
[rumext.v2 :as mf]
|
||||||
[shadow.resource]))
|
[shadow.resource]
|
||||||
|
[clojure.set :as set]))
|
||||||
|
|
||||||
(def lens:token-type-open-status
|
(def lens:token-type-open-status
|
||||||
(l/derived (l/in [:workspace-tokens :open-status]) st/state))
|
(l/derived (l/in [:workspace-tokens :open-status]) st/state))
|
||||||
|
@ -168,10 +169,14 @@
|
||||||
(mf/defc token-sets
|
(mf/defc token-sets
|
||||||
[_props]
|
[_props]
|
||||||
(let [active-theme-ids (mf/deref refs/workspace-active-theme-ids)
|
(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 (mf/deref refs/workspace-ordered-token-themes)
|
||||||
themes-index (mf/deref refs/workspace-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)
|
selected-token-set-id (mf/deref refs/workspace-selected-token-set-id)
|
||||||
token-sets (mf/deref refs/workspace-token-sets)]
|
token-sets (mf/deref refs/workspace-token-sets)]
|
||||||
[:div
|
[:div
|
||||||
|
@ -234,7 +239,7 @@
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
(st/emit! (wdt/toggle-token-set id)))}
|
(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]
|
[:button {:on-click (fn [e]
|
||||||
(dom/prevent-default e)
|
(dom/prevent-default e)
|
||||||
(dom/stop-propagation e)
|
(dom/stop-propagation e)
|
||||||
|
|
|
@ -59,6 +59,13 @@
|
||||||
(or temp-theme-id-set #{})
|
(or temp-theme-id-set #{})
|
||||||
new-themes)))
|
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
|
(defn update-theme-id
|
||||||
[state]
|
[state]
|
||||||
(let [active-themes (get-active-theme-ids state)
|
(let [active-themes (get-active-theme-ids state)
|
||||||
|
|
Loading…
Add table
Reference in a new issue