From 5e39f33bff37ee7e4cc572095ace1e4f744d7d33 Mon Sep 17 00:00:00 2001 From: Florian Schroedl Date: Tue, 24 Sep 2024 11:06:12 +0200 Subject: [PATCH] Rename with theme prefix --- common/src/app/common/types/tokens_lib.cljc | 24 +++++++++---------- .../common_tests/types/tokens_lib_test.cljc | 22 ++++++++--------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 7271b850a..41ccce46e 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -328,10 +328,10 @@ (get-theme-groups [_] "get a sequence of group names by order") (get-active-theme-paths [_] "get the active theme paths") (get-active-themes [_] "get an ordered sequence of active themes in the library") - (active? [_ group name] "predicate if token theme is active") - (activate [_ group name] "adds theme from the active-themes") - (deactivate [_ group name] "removes theme from the active-themes") - (toggle-active? [_ group name] "toggles theme in the active-themes")) + (theme-active? [_ group name] "predicate if token theme is active") + (activate-theme [_ group name] "adds theme from the active-themes") + (deactivate-theme [_ group name] "removes theme from the active-themes") + (toggle-theme-active? [_ group name] "toggles theme in the active-themes")) (def schema:token-themes [:and @@ -483,7 +483,7 @@ (get-theme [_ group name] (dm/get-in themes [group name])) - (activate [this group name] + (activate-theme [this group name] (if (get-theme this group name) (let [group-themes (->> (get themes group) (map (comp token-theme->path val)) @@ -500,19 +500,19 @@ themes active-themes))) - (deactivate [_ group name] + (deactivate-theme [_ group name] (TokensLib. sets set-groups themes (disj active-themes (theme-path group name)))) - (active? [_ group name] + (theme-active? [_ group name] (contains? active-themes (theme-path group name))) - (toggle-active? [this group name] - (if (active? this group name) - (deactivate this group name) - (activate this group name))) + (toggle-theme-active? [this group name] + (if (theme-active? this group name) + (deactivate-theme this group name) + (activate-theme this group name))) (get-active-theme-paths [_] active-themes) @@ -522,7 +522,7 @@ (list) (comp (filter (partial instance? TokenTheme)) - (filter #(active? this (:group %) (:name %)))) + (filter #(theme-active? this (:group %) (:name %)))) (tree-seq d/ordered-map? vals themes))) ITokensLib diff --git a/common/test/common_tests/types/tokens_lib_test.cljc b/common/test/common_tests/types/tokens_lib_test.cljc index e0abee489..d12628cc5 100644 --- a/common/test/common_tests/types/tokens_lib_test.cljc +++ b/common/test/common_tests/types/tokens_lib_test.cljc @@ -397,9 +397,9 @@ (let [tokens-lib (-> (ctob/make-tokens-lib) (ctob/add-theme (ctob/make-token-theme :group "" :name "other-theme")) (ctob/add-theme (ctob/make-token-theme :group "" :name "theme-1")) - (ctob/activate "" "theme-1") + (ctob/activate-theme "" "theme-1") (ctob/add-theme (ctob/make-token-theme :group "group-1" :name "theme-2")) - (ctob/activate "group-1" "theme-2")) + (ctob/activate-theme "group-1" "theme-2")) expected-active-themes (->> (ctob/get-active-themes tokens-lib) (map #(select-keys % [:name :group])))] @@ -416,26 +416,26 @@ (ctob/add-theme (ctob/make-token-theme :group "group-1" :name "theme-2"))) tokens-lib' (-> tokens-lib - (ctob/activate "group-1" "theme-1") - (ctob/activate "group-1" "theme-2"))] + (ctob/activate-theme "group-1" "theme-1") + (ctob/activate-theme "group-1" "theme-2"))] - (t/is (not (ctob/active? tokens-lib' "group-1" "theme-1")) "theme-1 should be de-activated") - (t/is (ctob/active? tokens-lib' "group-1" "theme-2") "theme-1 should be activated"))) + (t/is (not (ctob/theme-active? tokens-lib' "group-1" "theme-1")) "theme-1 should be de-activated") + (t/is (ctob/theme-active? tokens-lib' "group-1" "theme-2") "theme-1 should be activated"))) (t/deftest toggle-theme-activity (let [tokens-lib (-> (ctob/make-tokens-lib) (ctob/add-theme (ctob/make-token-theme :group "group-1" :name "theme-1")) - (ctob/toggle-active? "group-1" "theme-1")) + (ctob/toggle-theme-active? "group-1" "theme-1")) tokens-lib' (-> tokens-lib - (ctob/toggle-active? "group-1" "theme-1"))] + (ctob/toggle-theme-active? "group-1" "theme-1"))] - (t/is (ctob/active? tokens-lib "group-1" "theme-1") "theme-1 should be activated") - (t/is (not (ctob/active? tokens-lib' "group-1" "theme-2")) "theme-1 got deactivated by toggling"))) + (t/is (ctob/theme-active? tokens-lib "group-1" "theme-1") "theme-1 should be activated") + (t/is (not (ctob/theme-active? tokens-lib' "group-1" "theme-2")) "theme-1 got deactivated by toggling"))) (t/deftest activating-missing-theme-noop (let [tokens-lib (-> (ctob/make-tokens-lib) - (ctob/toggle-active? "group-1" "theme-1"))] + (ctob/toggle-theme-active? "group-1" "theme-1"))] (t/is (= #{} (ctob/get-active-theme-paths tokens-lib)) "Should not non-existing theme to the active-themes"))))