mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Add token set visibility toggle
This commit is contained in:
parent
636c3b822c
commit
6a7ced3204
3 changed files with 24 additions and 2 deletions
|
@ -134,6 +134,18 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/commit-changes changes)))))))
|
(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]
|
(defn delete-token-set [token-set-id]
|
||||||
(ptk/reify ::delete-token-set
|
(ptk/reify ::delete-token-set
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
|
|
@ -178,10 +178,11 @@
|
||||||
{:style {:display "flex"
|
{:style {:display "flex"
|
||||||
:flex-direction "column"
|
:flex-direction "column"
|
||||||
:gap "10px"
|
:gap "10px"
|
||||||
:max-height "350px"
|
:max-height "60vh"
|
||||||
:overflow "auto"
|
:overflow "auto"
|
||||||
:border-bottom "2px solid grey"
|
:border-bottom "2px solid grey"
|
||||||
:padding "10px"}}
|
:padding "10px"
|
||||||
|
:margin-bottom "50px"}}
|
||||||
|
|
||||||
(str "Themes (selected: " selected-theme-id ")")
|
(str "Themes (selected: " selected-theme-id ")")
|
||||||
[:div
|
[:div
|
||||||
|
@ -222,6 +223,10 @@
|
||||||
[:div {:style {:display "flex"
|
[:div {:style {:display "flex"
|
||||||
:gap "5px"}}
|
:gap "5px"}}
|
||||||
[:button
|
[: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)
|
(if (wtts/token-set-enabled-in-theme? id selected-theme)
|
||||||
"👁️"
|
"👁️"
|
||||||
" ")]
|
" ")]
|
||||||
|
|
|
@ -38,6 +38,11 @@
|
||||||
(defn add-token-set-to-token-theme [token-set-id token-theme]
|
(defn add-token-set-to-token-theme [token-set-id token-theme]
|
||||||
(update token-theme :sets conj token-set-id))
|
(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]
|
(defn token-set-enabled-in-theme? [set-id theme]
|
||||||
(some? (get-in theme [:sets set-id])))
|
(some? (get-in theme [:sets set-id])))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue