From d6823e8583100f744a0ac660818f608395e7e526 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Tue, 27 Aug 2024 14:49:11 +0200 Subject: [PATCH] Always switch to temporary theme when toggling sets in sidebar --- frontend/src/app/main/data/tokens.cljs | 11 ++++++----- .../app/main/ui/workspace/tokens/modals/themes.cljs | 2 +- frontend/src/app/main/ui/workspace/tokens/sets.cljs | 4 +++- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index 39297ba1c..e13527db0 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -179,18 +179,19 @@ (rx/of (dch/commit-changes changes)))))) -(defn toggle-token-set [{:keys [token-set-id token-theme-id]}] +(defn toggle-token-set [{:keys [token-set-id]}] (ptk/reify ::toggle-token-set ptk/WatchEvent (watch [it state _] - (js/console.log "token-set-id token-theme-id" token-set-id token-theme-id) - (let [theme (some-> (or token-theme-id (wtts/update-theme-id state)) - (wtts/get-workspace-token-theme state)) + (let [target-theme-id (wtts/get-temp-theme-id state) + active-set-ids (wtts/get-active-set-ids state) + theme (-> (wtts/get-workspace-token-theme target-theme-id state) + (assoc :sets active-set-ids)) changes (-> (pcb/empty-changes it) (pcb/update-token-theme (wtts/toggle-token-set-to-token-theme token-set-id theme) theme) - (pcb/update-active-token-themes #{(wtts/update-theme-id state)} (wtts/get-active-theme-ids state)))] + (pcb/update-active-token-themes #{target-theme-id} (wtts/get-active-theme-ids state)))] (rx/of (dch/commit-changes changes) (wtu/update-workspace-tokens)))))) diff --git a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs index c5dded93e..91c949826 100644 --- a/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/modals/themes.cljs @@ -163,7 +163,7 @@ :token-set-selected? (constantly false) :token-set-active? token-set-active? :on-select on-toggle-token-set - :on-toggle on-toggle-token-set + :on-toggle-token-set on-toggle-token-set :context sets-context/static-context}]] [:div {:class (stl/css :edit-theme-footer)} (if edit? diff --git a/frontend/src/app/main/ui/workspace/tokens/sets.cljs b/frontend/src/app/main/ui/workspace/tokens/sets.cljs index 9f5603efb..aee24445c 100644 --- a/frontend/src/app/main/ui/workspace/tokens/sets.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/sets.cljs @@ -128,6 +128,7 @@ token-set-selected? token-set-active? on-create-token-set + on-toggle-token-set on-select context] :as _props}] @@ -141,6 +142,7 @@ :editing? editing? :on-select on-select :on-edit on-edit + :on-toggle on-toggle-token-set :on-submit #(do (on-update-token-set %) (on-reset)) @@ -175,6 +177,6 @@ :token-set-selected? token-set-selected? :token-set-active? token-set-active? :on-select on-select-token-set-click - :on-toggle on-toggle-token-set-click + :on-toggle-token-set on-toggle-token-set-click :on-update-token-set on-update-token-set :on-create-token-set on-create-token-set}]))