diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index 9954bf183..6c000e4b3 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -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 diff --git a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs index 6a9f3107a..0bfd0b491 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sidebar.cljs @@ -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) "👁️" " ")] diff --git a/frontend/src/app/main/ui/workspace/tokens/token_set.cljs b/frontend/src/app/main/ui/workspace/tokens/token_set.cljs index 1ffb3288e..5a9c73764 100644 --- a/frontend/src/app/main/ui/workspace/tokens/token_set.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/token_set.cljs @@ -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])))