mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
✨ Adds constraints to export/import
This commit is contained in:
parent
d6e009ce78
commit
8952cb4e00
2 changed files with 27 additions and 10 deletions
|
@ -70,6 +70,11 @@
|
||||||
(obj/set! "penpot:center-x" (-> center :x str))
|
(obj/set! "penpot:center-x" (-> center :x str))
|
||||||
(obj/set! "penpot:center-y" (-> center :y str))
|
(obj/set! "penpot:center-y" (-> center :y str))
|
||||||
|
|
||||||
|
;; Constraints
|
||||||
|
(add! :constraints-h)
|
||||||
|
(add! :constraints-v)
|
||||||
|
(add! :fixed-scroll)
|
||||||
|
|
||||||
(cond-> (and rect? (some? (:r1 shape)))
|
(cond-> (and rect? (some? (:r1 shape)))
|
||||||
(-> (add! :r1)
|
(-> (add! :r1)
|
||||||
(add! :r2)
|
(add! :r2)
|
||||||
|
@ -105,14 +110,14 @@
|
||||||
|
|
||||||
(mf/defc export-page
|
(mf/defc export-page
|
||||||
[{:keys [options]}]
|
[{:keys [options]}]
|
||||||
[:> "penpot:page" #js {}
|
(let [saved-grids (get options :saved-grids)]
|
||||||
(let [saved-grids (get options :saved-grids)]
|
(when-not (empty? saved-grids)
|
||||||
(when-not (empty? saved-grids)
|
(let [parse-grid
|
||||||
(let [parse-grid
|
(fn [[type params]]
|
||||||
(fn [[type params]]
|
{:type type :params params})
|
||||||
{:type type :params params})
|
grids (->> saved-grids (mapv parse-grid))]
|
||||||
grids (->> saved-grids (mapv parse-grid))]
|
[:> "penpot:page" #js {}
|
||||||
[:& export-grid-data {:grids grids}])))])
|
[:& export-grid-data {:grids grids}]]))))
|
||||||
|
|
||||||
(mf/defc export-data
|
(mf/defc export-data
|
||||||
[{:keys [shape]}]
|
[{:keys [shape]}]
|
||||||
|
|
|
@ -267,7 +267,10 @@
|
||||||
flip-y (get-meta node :flip-y str->bool)
|
flip-y (get-meta node :flip-y str->bool)
|
||||||
proportion (get-meta node :proportion d/parse-double)
|
proportion (get-meta node :proportion d/parse-double)
|
||||||
proportion-lock (get-meta node :proportion-lock str->bool)
|
proportion-lock (get-meta node :proportion-lock str->bool)
|
||||||
rotation (get-meta node :rotation d/parse-double)]
|
rotation (get-meta node :rotation d/parse-double)
|
||||||
|
constraints-h (get-meta node :constraints-h keyword)
|
||||||
|
constraints-v (get-meta node :constraints-v keyword)
|
||||||
|
fixed-scroll (get-meta node :fixed-scroll str->bool)]
|
||||||
|
|
||||||
(-> props
|
(-> props
|
||||||
(assoc :name name)
|
(assoc :name name)
|
||||||
|
@ -279,7 +282,16 @@
|
||||||
(assoc :flip-y flip-y)
|
(assoc :flip-y flip-y)
|
||||||
(assoc :proportion proportion)
|
(assoc :proportion proportion)
|
||||||
(assoc :proportion-lock proportion-lock)
|
(assoc :proportion-lock proportion-lock)
|
||||||
(assoc :rotation rotation))))
|
(assoc :rotation rotation)
|
||||||
|
|
||||||
|
(cond-> (some? constraints-h)
|
||||||
|
(assoc :constraints-h constraints-h))
|
||||||
|
|
||||||
|
(cond-> (some? constraints-v)
|
||||||
|
(assoc :constraints-v constraints-v))
|
||||||
|
|
||||||
|
(cond-> (some? fixed-scroll)
|
||||||
|
(assoc :fixed-scroll fixed-scroll)))))
|
||||||
|
|
||||||
(defn add-position
|
(defn add-position
|
||||||
[props type node svg-data]
|
[props type node svg-data]
|
||||||
|
|
Loading…
Reference in a new issue