Fix export

This commit is contained in:
Florian Schroedl 2024-10-02 10:52:48 +02:00
parent fdca6e4edf
commit 845de5d885

View file

@ -61,18 +61,18 @@
(defn export-tokens-file [tokens-json] (defn export-tokens-file [tokens-json]
(let [file-name "tokens.json" (let [file-name "tokens.json"
file-content (encode-tokens tokens-json) file-content (encode-tokens tokens-json)
blob (wapi/create-blob (clj->js file-content) "application/json")] blob (wapi/create-blob file-content "application/json")]
(dom/trigger-download file-name blob))) (dom/trigger-download file-name blob)))
(defn transform-tokens-into-json-format [tokens] (defn tokens->dtcg-map [tokens]
(let [global (reduce (let [global (reduce
(fn [acc [_ {:keys [name value type]}]] (fn [acc [_ {:keys [name value type]}]]
(assoc acc name {:$value value (assoc acc name {"$value" value
:$type (str/camel type)})) "$type" (str/camel type)}))
(sorted-map) tokens)] (d/ordered-map) tokens)]
{:global global})) {:global global}))
(defn download-tokens-as-json [] (defn download-tokens-as-json []
(let [all-tokens (deref refs/workspace-selected-token-set-tokens-OLD) (let [tokens (deref refs/workspace-active-theme-sets-tokens)
transformed-tokens-json (transform-tokens-into-json-format all-tokens)] dtcg-format-tokens-map (tokens->dtcg-map tokens)]
(export-tokens-file transformed-tokens-json))) (export-tokens-file dtcg-format-tokens-map)))