From 19ce9e8ce39a741a197208cc06e2a2a779fc0dd7 Mon Sep 17 00:00:00 2001 From: Andrey Fedorov Date: Tue, 10 Dec 2024 11:55:33 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Include=20themes=20to=20dtcg=20enco?= =?UTF-8?q?ding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/app/common/types/tokens_lib.cljc | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/common/src/app/common/types/tokens_lib.cljc b/common/src/app/common/types/tokens_lib.cljc index 1df9c698ce..e9ecdfa846 100644 --- a/common/src/app/common/types/tokens_lib.cljc +++ b/common/src/app/common/types/tokens_lib.cljc @@ -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