mirror of
https://github.com/penpot/penpot.git
synced 2026-11-23 19:00:36 +00:00
🐛 Keep a theme's disabled sets out of it when importing tokens
Importing a tokens JSON whose `$themes` list a set as "disabled" in `selectedTokenSets` made that set part of the theme, so activating the theme turned it on: every key of `selectedTokenSets` was taken, whatever its state. A theme now takes only the sets that are not "disabled". Found by the components Qase run (Library Tokens suite). Test: `parse-theme-leaves-out-its-disabled-sets` (tokens-lib-test). AI-assisted-by: claude-opus-5-5
This commit is contained in:
parent
36f0f3089d
commit
3837ee5ff5
@ -1660,7 +1660,7 @@
|
||||
:is-source is-source
|
||||
:external-id id
|
||||
:sets (into #{}
|
||||
(comp (remove (comp #{:disabled} val))
|
||||
(comp (remove (comp #{:disabled "disabled"} val))
|
||||
(map key)
|
||||
xf-normalize-set-name
|
||||
(filter #(contains? sets %)))
|
||||
|
||||
@ -1215,6 +1215,17 @@
|
||||
:value "16px"
|
||||
:description ""}))))))
|
||||
|
||||
(t/deftest parse-theme-leaves-out-its-disabled-sets
|
||||
(let [json {"light" {"color" {"$type" "color" "$value" "#ffffff"}}
|
||||
"dark" {"color" {"$type" "color" "$value" "#000000"}}
|
||||
"$themes" [{"name" "Light"
|
||||
"group" ""
|
||||
"selectedTokenSets" {"light" "enabled"
|
||||
"dark" "disabled"}}]
|
||||
"$metadata" {"tokenSetOrder" ["light" "dark"]}}
|
||||
lib (ctob/parse-decoded-json json "imported")]
|
||||
(t/is (= #{"light"} (:sets (ctob/get-theme-by-name lib "" "Light"))))))
|
||||
|
||||
#?(:clj
|
||||
(t/deftest parse-multi-set-legacy-json
|
||||
(let [json (-> (slurp "test/common_tests/types/data/tokens-multi-set-legacy-example.json")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user