mirror of
https://github.com/penpot/penpot.git
synced 2025-06-07 10:31:38 +02:00
Move the shape initialization out of add-shape event.
This commit is contained in:
parent
3ae0306632
commit
bc756337cd
1 changed files with 6 additions and 12 deletions
|
@ -14,12 +14,6 @@
|
||||||
;; Schemas
|
;; Schemas
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(def ^:static +shape-props-schema+
|
|
||||||
{:x [v/integer]
|
|
||||||
:y [v/integer]
|
|
||||||
:width [v/integer]
|
|
||||||
:height [v/integer]})
|
|
||||||
|
|
||||||
(def ^:static +shape-schema+
|
(def ^:static +shape-schema+
|
||||||
{:x [v/integer]
|
{:x [v/integer]
|
||||||
:y [v/integer]
|
:y [v/integer]
|
||||||
|
@ -41,8 +35,10 @@
|
||||||
:opacity [v/number]})
|
:opacity [v/number]})
|
||||||
|
|
||||||
(def ^:static +shape-update-position-schema+
|
(def ^:static +shape-update-position-schema+
|
||||||
{:x [v/integer]
|
{:x1 [v/integer]
|
||||||
:y [v/integer]})
|
:y1 [v/integer]
|
||||||
|
:x2 [v/integer]
|
||||||
|
:y2 [v/integer]})
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Events (explicit)
|
;; Events (explicit)
|
||||||
|
@ -125,16 +121,14 @@
|
||||||
|
|
||||||
(defn add-shape
|
(defn add-shape
|
||||||
"Create and add shape to the current selected page."
|
"Create and add shape to the current selected page."
|
||||||
[shape props]
|
[shape]
|
||||||
(sc/validate! +shape-schema+ shape)
|
(sc/validate! +shape-schema+ shape)
|
||||||
(sc/validate! +shape-props-schema+ props)
|
|
||||||
(reify
|
(reify
|
||||||
rs/UpdateEvent
|
rs/UpdateEvent
|
||||||
(-apply-update [_ state]
|
(-apply-update [_ state]
|
||||||
(let [sid (random-uuid)
|
(let [sid (random-uuid)
|
||||||
pid (get-in state [:workspace :page])
|
pid (get-in state [:workspace :page])
|
||||||
shape (merge (sh/-initialize shape props)
|
shape (merge shape {:id sid :page pid})]
|
||||||
shape {:id sid :page pid})]
|
|
||||||
(as-> state $
|
(as-> state $
|
||||||
(update-in $ [:pages-by-id pid :shapes] conj sid)
|
(update-in $ [:pages-by-id pid :shapes] conj sid)
|
||||||
(assoc-in $ [:shapes-by-id sid] shape))))))
|
(assoc-in $ [:shapes-by-id sid] shape))))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue