mirror of
https://github.com/penpot/penpot.git
synced 2025-01-06 14:50:20 -05:00
Rename with theme prefix
This commit is contained in:
parent
416297d298
commit
5e39f33bff
2 changed files with 23 additions and 23 deletions
|
@ -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
|
||||
|
|
|
@ -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"))))
|
||||
|
||||
|
|
Loading…
Reference in a new issue