mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
Merge branch 'fix-token-reference-issue' into 199-branch-name
This commit is contained in:
commit
6da855c741
1 changed files with 9 additions and 5 deletions
|
@ -82,14 +82,18 @@
|
|||
(and (set? errors)
|
||||
(get errors :style-dictionary/missing-reference)))
|
||||
|
||||
(defn tokens-name-map [tokens]
|
||||
(->> tokens
|
||||
(map (fn [[_ x]] [(:name x) x]))
|
||||
(into {})))
|
||||
(defn tokens-name-tree [tokens]
|
||||
(reduce
|
||||
(fn [acc [_ {:keys [name] :as token}]]
|
||||
(if (string? name)
|
||||
(let [name-path (->> (str/split name #"\.")
|
||||
(remove str/blank?))]
|
||||
(assoc-in acc name-path token))))
|
||||
{} tokens))
|
||||
|
||||
(defn resolve-tokens+
|
||||
[tokens & {:keys [debug?] :as config}]
|
||||
(p/let [sd-tokens (-> (tokens-name-map tokens)
|
||||
(p/let [sd-tokens (-> (tokens-name-tree tokens)
|
||||
(resolve-sd-tokens+ config))]
|
||||
(let [resolved-tokens (reduce
|
||||
(fn [acc ^js cur]
|
||||
|
|
Loading…
Add table
Reference in a new issue