0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-20 05:34:23 -05:00

Include themes to dtcg encoding

This commit is contained in:
Andrey Fedorov 2024-12-10 11:55:33 +01:00
parent 9d67d007fb
commit 19ce9e8ce3

View file

@ -884,11 +884,20 @@ When `before-set-name` is nil, move set to bottom")
(d/ordered-map) active-themes)))
(encode-dtcg [_]
(into {} (comp
(filter (partial instance? TokenSet))
(map (fn [token-set]
[(:name token-set) (get-dtcg-tokens-tree token-set)])))
(tree-seq d/ordered-map? vals sets)))
(let [themes (into []
(comp
(filter (partial instance? TokenTheme))
(map (fn [token-theme]
(into {} token-theme))))
(tree-seq d/ordered-map? vals themes))
themes-set-names (apply clojure.set/union (map :sets themes))
sets (into {} (comp
(filter #(and (instance? TokenSet %)
(contains? themes-set-names (:name %))))
(map (fn [token-set]
[(:name token-set) (get-dtcg-tokens-tree token-set)])))
(tree-seq d/ordered-map? vals sets))]
(assoc sets :$themes themes)))
(decode-dtcg-json [_ parsed-json]
(let [;; tokens-studio/plugin will add these meta properties, remove them for now