mirror of
https://github.com/penpot/penpot.git
synced 2025-03-11 07:11:32 -05:00
Allow passing of tokens
This commit is contained in:
parent
b1b6b5292c
commit
0921f8043b
1 changed files with 19 additions and 16 deletions
|
@ -41,7 +41,7 @@
|
|||
(js/console.log "Input Data" js-data))
|
||||
(StyleDictionary. js-data)))
|
||||
|
||||
(defn resolve-tokens+
|
||||
(defn resolve-sd-tokens+
|
||||
"Resolves references and math expressions using StyleDictionary.
|
||||
Returns a promise with the resolved dictionary."
|
||||
[tokens & {:keys [debug?] :as config}]
|
||||
|
@ -61,22 +61,25 @@
|
|||
(js/console.log "Resolved tokens" resolved-tokens))
|
||||
resolved-tokens))))))
|
||||
|
||||
(defn resolve-workspace-tokens+
|
||||
[& {:keys [debug?] :as config}]
|
||||
(when-let [workspace-tokens @refs/workspace-tokens]
|
||||
(p/let [sd-tokens (-> workspace-tokens
|
||||
(tokens->tree)
|
||||
(defn resolve-tokens+
|
||||
[tokens & {:keys [debug?] :as config}]
|
||||
(p/let [sd-tokens (-> (tokens->tree tokens)
|
||||
(clj->js)
|
||||
(resolve-tokens+ config))]
|
||||
(resolve-sd-tokens+ config))]
|
||||
(let [resolved-tokens (reduce
|
||||
(fn [acc cur]
|
||||
(let [resolved-value (.-value cur)
|
||||
id (uuid (.-id cur))]
|
||||
(assoc-in acc [id :value] resolved-value)))
|
||||
workspace-tokens sd-tokens)]
|
||||
tokens sd-tokens)]
|
||||
(when debug?
|
||||
(js/console.log "Resolved tokens" resolved-tokens))
|
||||
resolved-tokens))))
|
||||
resolved-tokens)))
|
||||
|
||||
(defn resolve-workspace-tokens+
|
||||
[& {:keys [debug?] :as config}]
|
||||
(when-let [workspace-tokens @refs/workspace-tokens]
|
||||
(resolve-tokens+ workspace-tokens)))
|
||||
|
||||
;; Testing ---------------------------------------------------------------------
|
||||
|
||||
|
@ -98,9 +101,9 @@
|
|||
(tokens->tree)
|
||||
(clj->js)
|
||||
(#(doto % js/console.log))
|
||||
(resolve-tokens+ {:debug? true}))
|
||||
(resolve-sd-tokens+ {:debug? true}))
|
||||
|
||||
(-> (tokens-studio-example)
|
||||
(resolve-tokens+ {:debug? true}))
|
||||
(resolve-sd-tokens+ {:debug? true}))
|
||||
|
||||
nil)
|
||||
|
|
Loading…
Add table
Reference in a new issue