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

Add token set visibility toggle

This commit is contained in:
Florian Schroedl 2024-08-16 13:36:54 +02:00
parent 636c3b822c
commit 6a7ced3204
3 changed files with 24 additions and 2 deletions

View file

@ -134,6 +134,18 @@
(rx/of
(dch/commit-changes changes)))))))
(defn toggle-token-set [token-set-id]
(ptk/reify ::toggle-token-set
ptk/WatchEvent
(watch [it state _]
(let [theme (some-> (wtts/update-theme-id state)
(wtts/get-workspace-token-theme state))
changes (-> (pcb/empty-changes it)
(pcb/update-token-theme
(wtts/toggle-token-set-to-token-theme token-set-id theme)
theme))]
(rx/of (dch/commit-changes changes))))))
(defn delete-token-set [token-set-id]
(ptk/reify ::delete-token-set
ptk/WatchEvent

View file

@ -178,10 +178,11 @@
{:style {:display "flex"
:flex-direction "column"
:gap "10px"
:max-height "350px"
:max-height "60vh"
:overflow "auto"
:border-bottom "2px solid grey"
:padding "10px"}}
:padding "10px"
:margin-bottom "50px"}}
(str "Themes (selected: " selected-theme-id ")")
[:div
@ -222,6 +223,10 @@
[:div {:style {:display "flex"
:gap "5px"}}
[:button
{:on-click (fn [e]
(dom/prevent-default e)
(dom/stop-propagation e)
(st/emit! (wdt/toggle-token-set id)))}
(if (wtts/token-set-enabled-in-theme? id selected-theme)
"👁️"
" ")]

View file

@ -38,6 +38,11 @@
(defn add-token-set-to-token-theme [token-set-id token-theme]
(update token-theme :sets conj token-set-id))
(defn toggle-token-set-to-token-theme [token-set-id token-theme]
(update token-theme :sets #(if (get % token-set-id)
(disj % token-set-id)
(conj % token-set-id))))
(defn token-set-enabled-in-theme? [set-id theme]
(some? (get-in theme [:sets set-id])))