mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -05:00
Validate against names in all token sets
This commit is contained in:
parent
e363b58774
commit
6bae2efe9d
3 changed files with 18 additions and 3 deletions
|
@ -269,6 +269,9 @@
|
|||
(def workspace-active-theme-sets-tokens
|
||||
(l/derived wtts/get-active-theme-sets-tokens-names-map st/state =))
|
||||
|
||||
(def workspace-ordered-token-sets-tokens
|
||||
(l/derived wtts/get-workspace-ordered-sets-tokens st/state =))
|
||||
|
||||
(def workspace-selected-token-set-tokens
|
||||
(l/derived
|
||||
(fn [data]
|
||||
|
|
|
@ -144,7 +144,8 @@ Token names should only contain letters and digits separated by . characters.")}
|
|||
(mf/defc form
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [token token-type] :as _args}]
|
||||
(let [selected-set-tokens (mf/deref refs/workspace-selected-token-set-tokens)
|
||||
(let [tokens (mf/deref refs/workspace-ordered-token-sets-tokens)
|
||||
_ (js/console.log "tokens" tokens)
|
||||
active-theme-tokens (mf/deref refs/workspace-active-theme-sets-tokens)
|
||||
resolved-tokens (sd/use-resolved-tokens active-theme-tokens {:names-map? true
|
||||
:cache-atom form-token-cache-atom})
|
||||
|
@ -152,9 +153,9 @@ Token names should only contain letters and digits separated by . characters.")}
|
|||
(mf/deps (:name token))
|
||||
#(wtt/token-name->path (:name token)))
|
||||
selected-set-tokens-tree (mf/use-memo
|
||||
(mf/deps token-path selected-set-tokens)
|
||||
(mf/deps token-path tokens)
|
||||
(fn []
|
||||
(-> (wtt/token-names-tree selected-set-tokens)
|
||||
(-> (wtt/token-names-tree tokens)
|
||||
;; Allow setting editing token to it's own path
|
||||
(d/dissoc-in token-path))))
|
||||
|
||||
|
|
|
@ -122,6 +122,17 @@
|
|||
(->> (map (fn [id] [id (get token-sets id)]) top-level-set-ids)
|
||||
(into (ordered-map)))))
|
||||
|
||||
(defn get-workspace-ordered-sets-tokens [state]
|
||||
(let [sets (get-workspace-ordered-sets state)]
|
||||
(reduce
|
||||
(fn [acc [_ {:keys [tokens] :as sets}]]
|
||||
(reduce (fn [acc' token-id]
|
||||
(if-let [token (wtt/get-workspace-token token-id state)]
|
||||
(assoc acc' (wtt/token-identifier token) token)
|
||||
acc'))
|
||||
acc tokens))
|
||||
{} sets)))
|
||||
|
||||
(defn get-token-set [set-id state]
|
||||
(some-> (get-workspace-sets state)
|
||||
(get set-id)))
|
||||
|
|
Loading…
Add table
Reference in a new issue