mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 14:12:36 -05:00
Don't override original value, add resolved value, add missing reference error
This commit is contained in:
parent
d65d880845
commit
9261c53aff
1 changed files with 12 additions and 3 deletions
|
@ -71,6 +71,9 @@
|
||||||
(js/console.log "Resolved tokens" resolved-tokens))
|
(js/console.log "Resolved tokens" resolved-tokens))
|
||||||
resolved-tokens))))))
|
resolved-tokens))))))
|
||||||
|
|
||||||
|
(def errors
|
||||||
|
{:style-dictionary/missing-reference {:user/message "Could not resolve reference token with the name: %s"}})
|
||||||
|
|
||||||
(defn tokens-name-map [tokens]
|
(defn tokens-name-map [tokens]
|
||||||
(->> tokens
|
(->> tokens
|
||||||
(map (fn [[_ x]] [(:name x) x]))
|
(map (fn [[_ x]] [(:name x) x]))
|
||||||
|
@ -83,9 +86,15 @@
|
||||||
(resolve-sd-tokens+ config))]
|
(resolve-sd-tokens+ config))]
|
||||||
(let [resolved-tokens (reduce
|
(let [resolved-tokens (reduce
|
||||||
(fn [acc ^js cur]
|
(fn [acc ^js cur]
|
||||||
(let [resolved-value (d/parse-integer (.-value cur) (.-value cur))
|
(let [value (.-value cur)
|
||||||
id (uuid (.-uuid (.-id cur)))]
|
resolved-value (d/parse-integer (.-value cur))
|
||||||
(assoc-in acc [id :value] resolved-value)))
|
original-value (-> cur .-original .-value)
|
||||||
|
id (uuid (.-uuid (.-id cur)))
|
||||||
|
missing-reference? (and (not resolved-value)
|
||||||
|
(re-find #"\{" value)
|
||||||
|
(= value original-value))]
|
||||||
|
(cond-> (assoc-in acc [id :resolved-value] resolved-value)
|
||||||
|
missing-reference? (update-in [id :errors] (fnil conj #{}) :style-dictionary/missing-reference))))
|
||||||
tokens sd-tokens)]
|
tokens sd-tokens)]
|
||||||
(when debug?
|
(when debug?
|
||||||
(js/console.log "Resolved tokens" resolved-tokens))
|
(js/console.log "Resolved tokens" resolved-tokens))
|
||||||
|
|
Loading…
Add table
Reference in a new issue