0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

🐛 Fix two runtime errors when creating shapes from library

This commit is contained in:
Andrés Moya 2020-06-11 14:54:52 +02:00 committed by Andrey Antukh
parent 200983fb7c
commit ff5ec11bac
5 changed files with 20 additions and 15 deletions

View file

@ -194,9 +194,10 @@
(us/assert number? height)
(-> shape
(assoc :width width :height height)
(update :selrect (fn [shape]
(assoc :x2 (+ (:x1 shape) width)
:y2 (+ (:y1 shape) height))))))
(update :selrect (fn [selrect]
(assoc selrect
:x2 (+ (:x1 selrect) width)
:y2 (+ (:y1 selrect) height))))))
;; --- Setup (Initialize)

View file

@ -377,10 +377,10 @@
:height 1
:selrect {:x 0
:x1 0
:x2 0
:x2 1
:y 0
:y1 0
:y2 0
:y2 1
:width 1
:height 1}
:points []

View file

@ -542,9 +542,6 @@
(rx/of (add-shape shape))))))
;; --- Update Shape Attrs
(defn update-shape

View file

@ -13,6 +13,9 @@
[cuerdas.core :as str]
[rumext.alpha :as mf]
[uxbox.common.data :as d]
[uxbox.common.pages :as cp]
[uxbox.common.geom.shapes :as geom]
[uxbox.common.geom.point :as gpt]
[uxbox.main.ui.icons :as i]
[uxbox.main.data.workspace :as dw]
[uxbox.main.refs :as refs]
@ -50,17 +53,19 @@
(defmulti shape-from-item (fn [type _] type))
(defmethod shape-from-item :icons [_ item]
(-> item
(assoc :type :icon)
(assoc :width (-> item :metadata :width))
(assoc :height (-> item :metadata :height))))
(-> (cp/make-minimal-shape :icon)
(merge item)
(geom/resize (-> item :metadata :width) (-> item :metadata :height))
(geom/absolute-move (gpt/point 0 0))))
(defmethod shape-from-item :images [_ item]
(let [metadata (select-keys item [:width :height :thumb-width
:thumb-height :thumb-uri :uri])]
(-> item
(assoc :type :image)
(assoc :metadata metadata))))
(-> (cp/make-minimal-shape :image)
(merge item)
(assoc :metadata metadata)
(geom/resize (-> item :width) (-> item :height))
(geom/absolute-move (gpt/point 0 0)))))
;; --- Components

View file

@ -126,6 +126,7 @@
:on-change on-pos-y-change
:value (-> shape :selrect :y (math/precision 2))}]]])
;; ROTATION
(when (options :rotation)
[:div.row-flex
[:span.element-set-subtitle (t locale "workspace.options.rotation")]
@ -152,6 +153,7 @@
(d/coalesce 0)
(math/precision 2)))}]])
;; RADIUS
(when (options :radius)
[:div.row-flex
[:span.element-set-subtitle (t locale "workspace.options.radius")]