0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 01:21:21 -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) (us/assert number? height)
(-> shape (-> shape
(assoc :width width :height height) (assoc :width width :height height)
(update :selrect (fn [shape] (update :selrect (fn [selrect]
(assoc :x2 (+ (:x1 shape) width) (assoc selrect
:y2 (+ (:y1 shape) height)))))) :x2 (+ (:x1 selrect) width)
:y2 (+ (:y1 selrect) height))))))
;; --- Setup (Initialize) ;; --- Setup (Initialize)

View file

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

View file

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

View file

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

View file

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