diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 3a966bf68..397072f55 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -368,7 +368,8 @@ When `before-set-name` is nil, move set to bottom") (defprotocol ITokenTheme (set-sets [_ set-names] "set the active token sets") - (toggle-set [_ set-name] "togle a set used / not used in the theme") + (disable-set [_ set-name] "disable set in theme") + (toggle-set [_ set-name] "toggle a set enabled / disabled 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") (hidden-temporary-theme? [_] "if a theme is the (from the user ui) hidden temporary theme")) @@ -383,6 +384,9 @@ When `before-set-name` is nil, move set to bottom") (dt/now) set-names)) + (disable-set [this set-name] + (set-sets this (disj sets set-name))) + (toggle-set [this set-name] (set-sets this (if (sets set-name) (disj sets set-name) @@ -580,7 +584,12 @@ When `before-set-name` is nil, move set to bottom") (let [path (split-token-set-path set-name)] (TokensLib. (d/dissoc-in sets path) set-groups ;; TODO remove set-group if needed - themes + (walk/postwalk + (fn [form] + (if (instance? TokenTheme form) + (disable-set form set-name) + form)) + themes) active-themes))) ;; TODO Handle groups and nesting diff --git a/common/test/common_tests/types/tokens_lib_test.cljc b/common/test/common_tests/types/tokens_lib_test.cljc index e1061939c..c3bdb52a0 100644 --- a/common/test/common_tests/types/tokens_lib_test.cljc +++ b/common/test/common_tests/types/tokens_lib_test.cljc @@ -235,15 +235,18 @@ (t/deftest delete-token-set (let [tokens-lib (-> (ctob/make-tokens-lib) - (ctob/add-set (ctob/make-token-set :name "test-token-set"))) + (ctob/add-set (ctob/make-token-set :name "test-token-set")) + (ctob/add-theme (ctob/make-token-theme :name "test-token-theme" :sets #{"test-token-set"}))) tokens-lib' (-> tokens-lib (ctob/delete-set "test-token-set") (ctob/delete-set "not-existing-set")) - token-set' (ctob/get-set tokens-lib' "updated-name")] + token-set' (ctob/get-set tokens-lib' "updated-name") + token-theme' (ctob/get-theme tokens-lib' "" "test-token-theme")] (t/is (= (ctob/set-count tokens-lib') 0)) + (t/is (= (:sets token-theme') #{})) (t/is (nil? token-set')))) (t/deftest active-themes-set-names