mirror of
https://github.com/penpot/penpot.git
synced 2025-05-02 02:06:22 +02:00
Extract token apply function
This commit is contained in:
parent
4e3af1407d
commit
cdca00a986
1 changed files with 8 additions and 3 deletions
|
@ -55,15 +55,20 @@
|
||||||
(->> (map (fn [attr] [attr token-id]) attributes)
|
(->> (map (fn [attr] [attr token-id]) attributes)
|
||||||
(into {})))
|
(into {})))
|
||||||
|
|
||||||
|
(defn apply-token-id [{:keys [shape token-id attributes]}]
|
||||||
|
(let [token (token-from-attributes token-id attributes)]
|
||||||
|
(toggle-or-apply-token shape token)))
|
||||||
|
|
||||||
(defn update-token-from-attributes
|
(defn update-token-from-attributes
|
||||||
[{:keys [token-id shape-id attributes]}]
|
[{:keys [token-id shape-id attributes]}]
|
||||||
(ptk/reify ::update-token-from-attributes
|
(ptk/reify ::update-token-from-attributes
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
(let [shape (get-shape-from-state shape-id state)
|
(let [shape (get-shape-from-state shape-id state)
|
||||||
token (token-from-attributes token-id attributes)
|
applied-tokens (apply-token-id {:shape shape
|
||||||
next-applied-tokens (toggle-or-apply-token shape token)]
|
:token-id token-id
|
||||||
(rx/of (update-shape shape-id {:applied-tokens next-applied-tokens}))))))
|
:attributes attributes})]
|
||||||
|
(rx/of (update-shape shape-id {:applied-tokens applied-tokens}))))))
|
||||||
|
|
||||||
(defn add-token
|
(defn add-token
|
||||||
[token]
|
[token]
|
||||||
|
|
Loading…
Add table
Reference in a new issue