0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-08 16:18:11 -05:00

🐛 Fix padding prediction does not work with one shape

This commit is contained in:
Pablo Alba 2023-03-24 17:23:11 +01:00 committed by Alonso Torres
parent 300ad15f5a
commit 0f9ad0907e

View file

@ -143,17 +143,16 @@
(/ (- (- max-y min-y) all-height) (dec (count shapes)))
0)
layout-gap {:row-gap row-gap :column-gap column-gap}
layout-gap {:row-gap (max row-gap 0) :column-gap (max column-gap 0)}
parent-selrect (:selrect parent)
padding (when (and (not (nil? parent)) (> (count shapes) 1))
padding (when (and (not (nil? parent)) (> (count shapes) 0))
{:p1 (min (- min-y (:y1 parent-selrect)) (- (:y2 parent-selrect) max-y))
:p2 (min (- min-x (:x1 parent-selrect)) (- (:x2 parent-selrect) max-x))})]
(cond-> {:layout-flex-dir direction}
(not (nil? padding)) (assoc :layout-padding {:p1 (:p1 padding) :p2 (:p2 padding) :p3 (:p1 padding) :p4 (:p2 padding)}
:layout-align-items :center
:layout-gap layout-gap)))))
(not (nil? padding)) (assoc :layout-padding {:p1 (:p1 padding) :p2 (:p2 padding) :p3 (:p1 padding) :p4 (:p2 padding)})
(not (nil? layout-gap)) (assoc :layout-gap layout-gap)))))
(defn shapes->grid-params
"Given the shapes calculate its flex parameters (horizontal vs vertical, gaps, etc)"