mirror of
https://github.com/penpot/penpot.git
synced 2025-06-06 06:51:37 +02:00
Simplify token application
This commit is contained in:
parent
0d154679e9
commit
48c85d7200
2 changed files with 18 additions and 7 deletions
|
@ -59,10 +59,21 @@
|
|||
(let [token (token-from-attributes token-id attributes)]
|
||||
(toggle-or-apply-token shape token)))
|
||||
|
||||
(defn apply-token-to-shape [{:keys [shape _token-id _attributes] :as props}]
|
||||
(let [applied-tokens (apply-token-id-to-attributes props)]
|
||||
(defn apply-token-to-shape
|
||||
"When the passed `:token` is non-nil apply it to the `:applied-tokens` on a shape."
|
||||
[{:keys [shape token attributes] :as props}]
|
||||
(let [applied-tokens (apply-token-id-to-attributes {:shape shape
|
||||
:token-id (:id token)
|
||||
:attributes attributes})]
|
||||
(update shape :applied-tokens #(merge % applied-tokens))))
|
||||
|
||||
(defn maybe-apply-token-to-shape
|
||||
"When the passed `:token` is non-nil apply it to the `:applied-tokens` on a shape."
|
||||
[{:keys [shape token _attributes] :as props}]
|
||||
(if token
|
||||
(apply-token-to-shape props)
|
||||
shape))
|
||||
|
||||
(defn update-token-from-attributes
|
||||
[{:keys [token-id shape-id attributes]}]
|
||||
(ptk/reify ::update-token-from-attributes
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue