Add helper utility to convert name to path

This commit is contained in:
Florian Schroedl 2024-06-28 13:34:54 +02:00
parent 6da855c741
commit ef5f019200
3 changed files with 24 additions and 0 deletions

View file

@ -76,6 +76,12 @@
(cond-> (assoc item :label name)
(token-applied? item shape (or selected-attributes attributes)) (assoc :selected? true))))))
(defn name->path
"Splits token-name into a path vector split by `.` characters.
Will concatenate multiple `.` characters into one."
[token-name]
(str/split token-name #"\.+"))
;; Update functions ------------------------------------------------------------
(defn on-apply-token [{:keys [token token-type-props selected-shapes] :as _props}]

View file

@ -91,9 +91,12 @@
(assoc-in acc name-path token))))
{} tokens))
(tokens-name-tree @refs/workspace-tokens)
(defn resolve-tokens+
[tokens & {:keys [debug?] :as config}]
(p/let [sd-tokens (-> (tokens-name-tree tokens)
(doto js/console.log)
(resolve-sd-tokens+ config))]
(let [resolved-tokens (reduce
(fn [acc ^js cur]