mirror of
https://github.com/penpot/penpot.git
synced 2025-03-10 06:41:40 -05:00
Move radius updating to core
This commit is contained in:
parent
9bf763efb3
commit
ae2da534e9
2 changed files with 14 additions and 6 deletions
|
@ -50,7 +50,15 @@
|
||||||
|
|
||||||
;; Shape Update Functions ------------------------------------------------------
|
;; Shape Update Functions ------------------------------------------------------
|
||||||
|
|
||||||
(defn update-shape-radius [value shape-ids]
|
(defn update-shape-radius-single-corner [value shape-ids attribute]
|
||||||
|
(dch/update-shapes shape-ids
|
||||||
|
(fn [shape]
|
||||||
|
(when (ctsr/has-radius? shape)
|
||||||
|
(ctsr/set-radius-4 shape (first attribute) value)))
|
||||||
|
{:reg-objects? true
|
||||||
|
:attrs [:rx :ry :r1 :r2 :r3 :r4]}))
|
||||||
|
|
||||||
|
(defn update-shape-radius-all [value shape-ids]
|
||||||
(dch/update-shapes shape-ids
|
(dch/update-shapes shape-ids
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(when (ctsr/has-radius? shape)
|
(when (ctsr/has-radius? shape)
|
||||||
|
@ -203,7 +211,7 @@
|
||||||
[:border-radius
|
[:border-radius
|
||||||
{:title "Border Radius"
|
{:title "Border Radius"
|
||||||
:attributes ctt/border-radius-keys
|
:attributes ctt/border-radius-keys
|
||||||
:on-update-shape update-shape-radius
|
:on-update-shape update-shape-radius-all
|
||||||
:modal {:key :tokens/border-radius
|
:modal {:key :tokens/border-radius
|
||||||
:fields [{:label "Border Radius"
|
:fields [{:label "Border Radius"
|
||||||
:key :border-radius}]}}]
|
:key :border-radius}]}}]
|
||||||
|
|
|
@ -36,11 +36,11 @@
|
||||||
events [(wtc/apply-token {:shape-ids [(:id rect-1)]
|
events [(wtc/apply-token {:shape-ids [(:id rect-1)]
|
||||||
:attributes #{:rx :ry}
|
:attributes #{:rx :ry}
|
||||||
:token (toht/get-token file :token-1)
|
:token (toht/get-token file :token-1)
|
||||||
:on-update-shape wtc/update-shape-radius})
|
:on-update-shape wtc/update-shape-radius-all})
|
||||||
(wtc/apply-token {:shape-ids [(:id rect-1)]
|
(wtc/apply-token {:shape-ids [(:id rect-1)]
|
||||||
:attributes #{:rx :ry}
|
:attributes #{:rx :ry}
|
||||||
:token (toht/get-token file :token-2)
|
:token (toht/get-token file :token-2)
|
||||||
:on-update-shape wtc/update-shape-radius})]]
|
:on-update-shape wtc/update-shape-radius-all})]]
|
||||||
(tohs/run-store-async
|
(tohs/run-store-async
|
||||||
store done events
|
store done events
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
|
@ -63,7 +63,7 @@
|
||||||
events [(wtc/apply-token {:shape-ids [(:id rect-1)]
|
events [(wtc/apply-token {:shape-ids [(:id rect-1)]
|
||||||
:attributes #{:rx :ry}
|
:attributes #{:rx :ry}
|
||||||
:token (toht/get-token file :token-2)
|
:token (toht/get-token file :token-2)
|
||||||
:on-update-shape wtc/update-shape-radius})]]
|
:on-update-shape wtc/update-shape-radius-all})]]
|
||||||
(tohs/run-store-async
|
(tohs/run-store-async
|
||||||
store done events
|
store done events
|
||||||
(fn [new-state]
|
(fn [new-state]
|
||||||
|
@ -187,7 +187,7 @@
|
||||||
rect-2 (cths/get-shape file :rect-2)
|
rect-2 (cths/get-shape file :rect-2)
|
||||||
events [(wtc/toggle-token {:shapes [rect-1 rect-2]
|
events [(wtc/toggle-token {:shapes [rect-1 rect-2]
|
||||||
:token-type-props {:attributes #{:rx :ry}
|
:token-type-props {:attributes #{:rx :ry}
|
||||||
:on-update-shape wtc/update-shape-radius}
|
:on-update-shape wtc/update-shape-radius-all}
|
||||||
:token (toht/get-token file :token-2)})]]
|
:token (toht/get-token file :token-2)})]]
|
||||||
(tohs/run-store-async
|
(tohs/run-store-async
|
||||||
store done events
|
store done events
|
||||||
|
|
Loading…
Add table
Reference in a new issue