mirror of
https://github.com/penpot/penpot.git
synced 2025-01-21 06:02:32 -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,27 +30,29 @@
|
|||
;; Update functions ------------------------------------------------------------
|
||||
|
||||
(defn update-shape-radius [value shape-ids]
|
||||
(let [parsed-value (d/parse-integer value)]
|
||||
(dch/update-shapes shape-ids
|
||||
(fn [shape]
|
||||
(when (ctsr/has-radius? shape)
|
||||
(ctsr/set-radius-1 shape parsed-value)))
|
||||
{:reg-objects? true
|
||||
:attrs ctt/border-radius-keys})))
|
||||
(st/emit!
|
||||
(dch/update-shapes shape-ids
|
||||
(fn [shape]
|
||||
(when (ctsr/has-radius? shape)
|
||||
(ctsr/set-radius-1 shape value)))
|
||||
{:reg-objects? true
|
||||
:attrs ctt/border-radius-keys})))
|
||||
|
||||
;; Token types -----------------------------------------------------------------
|
||||
|
||||
(def token-types
|
||||
(ordered-map
|
||||
[:boolean {:title "Boolean"
|
||||
:modal {:key :tokens/boolean
|
||||
:fields [{:label "Boolean"}]}}]
|
||||
[:border-radius {:title "Border Radius"
|
||||
:attributes ctt/border-radius-keys
|
||||
:modal {:key :tokens/border-radius
|
||||
:fields [{:label "Border Radius"
|
||||
:key :border-radius}]}
|
||||
:on-update-shape update-shape-radius}]
|
||||
[:boolean
|
||||
{:title "Boolean"
|
||||
:modal {:key :tokens/boolean
|
||||
:fields [{:label "Boolean"}]}}]
|
||||
[:border-radius
|
||||
{:title "Border Radius"
|
||||
:attributes ctt/border-radius-keys
|
||||
:on-update-shape update-shape-radius
|
||||
:modal {:key :tokens/border-radius
|
||||
:fields [{:label "Border Radius"
|
||||
:key :border-radius}]}}]
|
||||
[:box-shadow
|
||||
{:title "Box Shadow"
|
||||
:modal {:key :tokens/box-shadow
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
(ns app.main.ui.workspace.tokens.sidebar
|
||||
(:require-macros [app.main.style :as stl])
|
||||
(:require
|
||||
[app.common.data :as d]
|
||||
[app.main.data.modal :as modal]
|
||||
[app.main.data.tokens :as dt]
|
||||
[app.main.refs :as refs]
|
||||
|
@ -25,12 +26,13 @@
|
|||
shape-ids (->> selected-shapes
|
||||
(eduction
|
||||
(remove #(tokens-applied? token % attributes))
|
||||
(map :id)))]
|
||||
(map :id)))
|
||||
token-value (d/parse-integer (:value token))]
|
||||
(doseq [shape selected-shapes]
|
||||
(st/emit! (on-apply {:token-id (:id token)
|
||||
:shape-id (:id shape)
|
||||
:attributes attributes}))
|
||||
(st/emit! (on-update-shape (:value token) shape-ids)))))
|
||||
(on-update-shape token-value shape-ids))))
|
||||
|
||||
(mf/defc token-pill
|
||||
{::mf/wrap-props false}
|
||||
|
|
Loading…
Add table
Reference in a new issue