From 5f6a76dfce9cbbf6e974f5734aafdefc3db80eec Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Thu, 26 Sep 2024 15:24:02 +0200 Subject: [PATCH] Use currently active sets as sets for temporary theme --- common/src/app/common/types/tokens_lib.cljc | 13 +++++++++---- frontend/src/app/main/data/tokens.cljs | 10 +++++++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 60b7b79f3e..7cf9837e1f 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -268,6 +268,7 @@ (token-theme-path hidden-token-theme-group hidden-token-theme-name)) (defprotocol ITokenTheme + (set-sets [_ set-names] "set the active token sets") (toggle-set [_ set-name] "togle a set used / not used in the theme") (theme-path [_] "get `token-theme-path` from theme") (theme-matches-group-name [_ group name] "if a theme matches the given group & name") @@ -275,15 +276,19 @@ (defrecord TokenTheme [name group description is-source modified-at sets] ITokenTheme - (toggle-set [_ set-name] + (set-sets [_ set-names] (TokenTheme. name group description is-source (dt/now) - (if (sets set-name) - (disj sets set-name) - (conj sets set-name)))) + set-names)) + + (toggle-set [this set-name] + (set-sets this (if (sets set-name) + (disj sets set-name) + (conj sets set-name)))) + (theme-path [_] (token-theme-path group name)) diff --git a/frontend/src/app/main/data/tokens.cljs b/frontend/src/app/main/data/tokens.cljs index 6a33024a23..990e6bea3f 100644 --- a/frontend/src/app/main/data/tokens.cljs +++ b/frontend/src/app/main/data/tokens.cljs @@ -217,9 +217,13 @@ (watch [it state _] (let [tokens-lib (get-tokens-lib state) prev-theme (ctob/get-theme tokens-lib ctob/hidden-token-theme-group ctob/hidden-token-theme-name) - theme (-> (or prev-theme (ctob/make-token-theme - :group ctob/hidden-token-theme-group - :name ctob/hidden-token-theme-name)) + active-token-set-names (ctob/get-active-themes-set-names tokens-lib) + theme (-> (or (some-> prev-theme + (ctob/set-sets active-token-set-names)) + (ctob/make-token-theme + :group ctob/hidden-token-theme-group + :name ctob/hidden-token-theme-name + :sets active-token-set-names)) (ctob/toggle-set token-set-name)) prev-active-token-themes (ctob/get-active-theme-paths tokens-lib) changes (-> (pcb/empty-changes it)