Import masks

This commit is contained in:
alonso.torres 2021-06-04 09:34:13 +02:00
parent 152bcf451a
commit cc2c249a07
2 changed files with 18 additions and 2 deletions

View file

@ -28,7 +28,10 @@
(-> props
(obj/set! ns-attr val))))
frame? (= :frame (:type shape))
text? (= :text (:type shape))]
group? (= :group (:type shape))
rect? (= :text (:type shape))
text? (= :text (:type shape))
mask? (and group? (:masked-group? shape))]
(-> props
(add! :name (-> shape :name))
(add! :blocked (-> shape (:blocked false) str))
@ -41,7 +44,7 @@
(add! :transform (-> shape (:transform (gmt/matrix)) str))
(add! :transform-inverse (-> shape (:transform-inverse (gmt/matrix)) str))
(cond-> (some? (:r1 shape))
(cond-> (and rect? (some? (:r1 shape)))
(-> (add! :r1 (-> shape (:r1 0) str))
(add! :r2 (-> shape (:r2 0) str))
(add! :r3 (-> shape (:r3 0) str))
@ -51,6 +54,9 @@
(-> (add! :grow-type (-> shape :grow-type))
(add! :content (-> shape :content json/encode))))
(cond-> mask?
(add! :masked-group "true"))
(cond-> frame?
(obj/set! "xmlns:penpot" "https://penpot.app/xmlns")))))

View file

@ -238,6 +238,13 @@
[val]
(= val "true"))
(defn add-group-data
[props node]
(let [mask? (get-meta node :masked-group str->bool)]
(cond-> props
mask?
(assoc :masked-group? true))))
(defn parse-data
[type node]
@ -257,6 +264,9 @@
(assoc :blocked blocked)
(assoc :hidden hidden)
(cond-> (= :group type)
(add-group-data node))
(cond-> (= :image type)
(add-image-data node data))