mirror of
https://github.com/penpot/penpot.git
synced 2025-05-01 16:46:22 +02:00
Cleanup function
This commit is contained in:
parent
0b081d24e0
commit
053d0fc923
2 changed files with 14 additions and 12 deletions
|
@ -627,16 +627,17 @@
|
||||||
(get-active-themes this)))
|
(get-active-themes this)))
|
||||||
|
|
||||||
(get-active-themes-set-tokens [this]
|
(get-active-themes-set-tokens [this]
|
||||||
(let [sets-order (get-sets-order this)]
|
(let [sets-order (get-sets-order this)
|
||||||
|
active-themes (get-active-themes this)
|
||||||
|
order-theme-set (fn [theme]
|
||||||
|
(filter #(contains? (set (:sets theme)) %) sets-order))]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc cur]
|
(fn [tokens theme]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc cur]
|
(fn [tokens' cur]
|
||||||
(merge acc (:tokens (get-set this cur))))
|
(merge tokens' (:tokens (get-set this cur))))
|
||||||
acc
|
tokens (order-theme-set theme)))
|
||||||
(let [ref-set (set (:sets cur))]
|
(d/ordered-map) active-themes)))
|
||||||
(filter #(contains? ref-set %) sets-order))))
|
|
||||||
(d/ordered-map) (get-active-themes this))))
|
|
||||||
|
|
||||||
(update-set-name [_ old-set-name new-set-name]
|
(update-set-name [_ old-set-name new-set-name]
|
||||||
(TokensLib. sets
|
(TokensLib. sets
|
||||||
|
|
|
@ -337,7 +337,7 @@
|
||||||
(ctob/add-token-in-set "set-b" (ctob/make-token :name "set-b-token"
|
(ctob/add-token-in-set "set-b" (ctob/make-token :name "set-b-token"
|
||||||
:type :boolean
|
:type :boolean
|
||||||
:value true))
|
:value true))
|
||||||
|
;; Ignore this set
|
||||||
(ctob/add-set (ctob/make-token-set :name "inactive-set"))
|
(ctob/add-set (ctob/make-token-set :name "inactive-set"))
|
||||||
(ctob/add-token-in-set "inactive-set" (ctob/make-token :name "inactive-set-token"
|
(ctob/add-token-in-set "inactive-set" (ctob/make-token :name "inactive-set-token"
|
||||||
:type :boolean
|
:type :boolean
|
||||||
|
@ -345,9 +345,10 @@
|
||||||
|
|
||||||
|
|
||||||
expected-order (ctob/get-sets-order tokens-lib)
|
expected-order (ctob/get-sets-order tokens-lib)
|
||||||
expected-tokens (ctob/get-active-themes-set-tokens tokens-lib)]
|
expected-tokens (ctob/get-active-themes-set-tokens tokens-lib)
|
||||||
(t/is (= expected-order '("set-a" "set-b")))
|
expected-token-names (mapv key expected-tokens)]
|
||||||
(t/is (= ["set-a-token" "set-b-token"] (map key expected-tokens))))))
|
(t/is (= '("set-a" "set-b" "inactive-set") expected-order))
|
||||||
|
(t/is (= ["set-a-token" "set-b-token"] expected-token-names)))))
|
||||||
|
|
||||||
|
|
||||||
(t/testing "token-theme in a lib"
|
(t/testing "token-theme in a lib"
|
||||||
|
|
Loading…
Add table
Reference in a new issue