mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 22:22:43 -05:00
Move emit to the shape update function [*]
[*] A shape update might need multiple emit functions
This commit is contained in:
parent
28e6db9bb4
commit
a9aac4c867
2 changed files with 22 additions and 18 deletions
|
@ -30,11 +30,11 @@
|
||||||
;; Update functions ------------------------------------------------------------
|
;; Update functions ------------------------------------------------------------
|
||||||
|
|
||||||
(defn update-shape-radius [value shape-ids]
|
(defn update-shape-radius [value shape-ids]
|
||||||
(let [parsed-value (d/parse-integer value)]
|
(st/emit!
|
||||||
(dch/update-shapes shape-ids
|
(dch/update-shapes shape-ids
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(when (ctsr/has-radius? shape)
|
(when (ctsr/has-radius? shape)
|
||||||
(ctsr/set-radius-1 shape parsed-value)))
|
(ctsr/set-radius-1 shape value)))
|
||||||
{:reg-objects? true
|
{:reg-objects? true
|
||||||
:attrs ctt/border-radius-keys})))
|
:attrs ctt/border-radius-keys})))
|
||||||
|
|
||||||
|
@ -42,15 +42,17 @@
|
||||||
|
|
||||||
(def token-types
|
(def token-types
|
||||||
(ordered-map
|
(ordered-map
|
||||||
[:boolean {:title "Boolean"
|
[:boolean
|
||||||
|
{:title "Boolean"
|
||||||
:modal {:key :tokens/boolean
|
:modal {:key :tokens/boolean
|
||||||
:fields [{:label "Boolean"}]}}]
|
:fields [{:label "Boolean"}]}}]
|
||||||
[:border-radius {:title "Border Radius"
|
[:border-radius
|
||||||
|
{:title "Border Radius"
|
||||||
:attributes ctt/border-radius-keys
|
:attributes ctt/border-radius-keys
|
||||||
|
:on-update-shape update-shape-radius
|
||||||
:modal {:key :tokens/border-radius
|
:modal {:key :tokens/border-radius
|
||||||
:fields [{:label "Border Radius"
|
:fields [{:label "Border Radius"
|
||||||
:key :border-radius}]}
|
:key :border-radius}]}}]
|
||||||
:on-update-shape update-shape-radius}]
|
|
||||||
[:box-shadow
|
[:box-shadow
|
||||||
{:title "Box Shadow"
|
{:title "Box Shadow"
|
||||||
:modal {:key :tokens/box-shadow
|
:modal {:key :tokens/box-shadow
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.ui.workspace.tokens.sidebar
|
(ns app.main.ui.workspace.tokens.sidebar
|
||||||
(:require-macros [app.main.style :as stl])
|
(:require-macros [app.main.style :as stl])
|
||||||
(:require
|
(:require
|
||||||
|
[app.common.data :as d]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
[app.main.data.tokens :as dt]
|
[app.main.data.tokens :as dt]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
|
@ -25,12 +26,13 @@
|
||||||
shape-ids (->> selected-shapes
|
shape-ids (->> selected-shapes
|
||||||
(eduction
|
(eduction
|
||||||
(remove #(tokens-applied? token % attributes))
|
(remove #(tokens-applied? token % attributes))
|
||||||
(map :id)))]
|
(map :id)))
|
||||||
|
token-value (d/parse-integer (:value token))]
|
||||||
(doseq [shape selected-shapes]
|
(doseq [shape selected-shapes]
|
||||||
(st/emit! (on-apply {:token-id (:id token)
|
(st/emit! (on-apply {:token-id (:id token)
|
||||||
:shape-id (:id shape)
|
:shape-id (:id shape)
|
||||||
:attributes attributes}))
|
:attributes attributes}))
|
||||||
(st/emit! (on-update-shape (:value token) shape-ids)))))
|
(on-update-shape token-value shape-ids))))
|
||||||
|
|
||||||
(mf/defc token-pill
|
(mf/defc token-pill
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
|
|
Loading…
Add table
Reference in a new issue