0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-21 06:02:32 -05:00

Move over helper

This commit is contained in:
Florian Schroedl 2024-10-03 15:18:41 +02:00
parent 5de1f450c1
commit b3e73b9abc
2 changed files with 9 additions and 7 deletions

View file

@ -143,6 +143,14 @@
(map second)
(into #{})))
(defn token-value-self-reference?
"Check if the token is self referencing with its `token-name` in `token-value`.
Simple 1 level check, doesn't account for circular self refernces across multiple tokens."
[token-name token-value]
(let [token-references (find-token-value-references token-value)
self-reference? (get token-references token-name)]
self-reference?))
(defn group-by-type [tokens]
(let [tokens' (if (or (map? tokens)
(d/ordered-map? tokens))

View file

@ -91,12 +91,6 @@ Token names should only contain letters and digits separated by . characters.")}
;; Component -------------------------------------------------------------------
(defn token-self-reference?
[token-name input]
(let [token-references (ctob/find-token-value-references input)
self-reference? (get token-references token-name)]
self-reference?))
(defn validate-token-value+
"Validates token value by resolving the value `input` using `StyleDictionary`.
Returns a promise of either resolved tokens or rejects with an error state."
@ -108,7 +102,7 @@ Token names should only contain letters and digits separated by . characters.")}
(empty? (str/trim value))
(p/rejected {:errors [{:error/code :error/empty-input}]})
(token-self-reference? token-name value)
(ctob/token-value-self-reference? token-name value)
(p/rejected {:errors [(wte/get-error-code :error.token/direct-self-reference)]})
:else