mirror of
https://github.com/penpot/penpot.git
synced 2025-06-11 16:01:38 +02:00
Add helper utility to convert name to path
This commit is contained in:
parent
6da855c741
commit
ef5f019200
3 changed files with 24 additions and 0 deletions
|
@ -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}]
|
||||
|
|
|
@ -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]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue