0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-06 14:50:20 -05:00

Cleanup function

This commit is contained in:
Florian Schroedl 2024-10-02 10:15:35 +02:00
parent 0b081d24e0
commit 053d0fc923
2 changed files with 14 additions and 12 deletions

View file

@ -627,16 +627,17 @@
(get-active-themes 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
(fn [acc cur]
(fn [tokens theme]
(reduce
(fn [acc cur]
(merge acc (:tokens (get-set this cur))))
acc
(let [ref-set (set (:sets cur))]
(filter #(contains? ref-set %) sets-order))))
(d/ordered-map) (get-active-themes this))))
(fn [tokens' cur]
(merge tokens' (:tokens (get-set this cur))))
tokens (order-theme-set theme)))
(d/ordered-map) active-themes)))
(update-set-name [_ old-set-name new-set-name]
(TokensLib. sets

View file

@ -337,7 +337,7 @@
(ctob/add-token-in-set "set-b" (ctob/make-token :name "set-b-token"
:type :boolean
:value true))
;; Ignore this 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"
:type :boolean
@ -345,9 +345,10 @@
expected-order (ctob/get-sets-order tokens-lib)
expected-tokens (ctob/get-active-themes-set-tokens tokens-lib)]
(t/is (= expected-order '("set-a" "set-b")))
(t/is (= ["set-a-token" "set-b-token"] (map key expected-tokens))))))
expected-tokens (ctob/get-active-themes-set-tokens tokens-lib)
expected-token-names (mapv 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"