0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

🐛 Fix issues on converting graphics to components

This commit is contained in:
Andrey Antukh 2023-06-01 07:48:11 +02:00
parent ea47ce30df
commit 7fa24fdc2f
2 changed files with 16 additions and 22 deletions

View file

@ -71,8 +71,8 @@
[:obj :map] [:obj :map]
[:page-id {:optional true} ::sm/uuid] [:page-id {:optional true} ::sm/uuid]
[:component-id {:optional true} ::sm/uuid] [:component-id {:optional true} ::sm/uuid]
[:frame-id {:optional true} ::sm/uuid] [:frame-id ::sm/uuid]
[:parent-id {:optional true} ::sm/uuid] [:parent-id {:optional true} [:maybe ::sm/uuid]]
[:index {:optional true} [:maybe :int]] [:index {:optional true} [:maybe :int]]
[:ignore-touched {:optional true} :boolean]]] [:ignore-touched {:optional true} :boolean]]]

View file

@ -9,7 +9,6 @@
[app.common.colors :as clr] [app.common.colors :as clr]
[app.common.data :as d] [app.common.data :as d]
[app.common.data.macros :as dm] [app.common.data.macros :as dm]
[app.common.exceptions :as ex]
[app.common.files.helpers :as cfh] [app.common.files.helpers :as cfh]
[app.common.geom.matrix :as gmt] [app.common.geom.matrix :as gmt]
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
@ -38,14 +37,12 @@
{:x 0 :y 0 :width 1 :height 1}) {:x 0 :y 0 :width 1 :height 1})
(defn- assert-valid-num [attr num] (defn- assert-valid-num [attr num]
(when-not (and (d/num? num) (dm/verify!
(<= num max-safe-int) ["%1 attribute has invalid value: %2" (d/name attr) num]
(>= num min-safe-int)) (and (d/num? num)
(ex/raise :type :assertion (<= num max-safe-int)
:code :expr-validation (>= num min-safe-int)))
:hint (str/ffmt "%1 attribute has invalid value: %2" (d/name attr) num)))
;; If the number is between 0-1 we round to 1 (same in negative form
(cond (cond
(and (> num 0) (< num 1)) 1 (and (> num 0) (< num 1)) 1
(and (< num 0) (> num -1)) -1 (and (< num 0) (> num -1)) -1
@ -53,22 +50,19 @@
(defn- assert-valid-pos-num (defn- assert-valid-pos-num
[attr num] [attr num]
(when-not (pos? num)
(ex/raise :type :assertion (dm/verify!
:code :expr-validation ["%1 attribute should be positive" (d/name attr)]
:hint (str/ffmt "%1 attribute should be positive" (d/name attr)))) (pos? num))
num) num)
(defn- assert-valid-blend-mode (defn- assert-valid-blend-mode
[mode] [mode]
(let [clean-value (-> mode (let [clean-value (-> mode str/trim str/lower keyword)]
str/trim (dm/verify!
str/lower ["%1 is not a valid blend mode" clean-value]
keyword)] (contains? cts/blend-modes clean-value))
(when-not (contains? cts/blend-modes clean-value)
(ex/raise :type :assertion
:code :expr-validation
:hint (str/ffmt "%1 is not a valid blend mode" clean-value)))
clean-value)) clean-value))
(defn- svg-dimensions [data] (defn- svg-dimensions [data]