mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fixed some corner cases with grid parameters
This commit is contained in:
parent
cbfa60f2e7
commit
0611ce98a3
2 changed files with 13 additions and 5 deletions
|
@ -42,7 +42,16 @@
|
|||
:stroke-width (str (/ 1 zoom))}}])]])))
|
||||
|
||||
(mf/defc layout-grid [{:keys [key frame zoom grid]}]
|
||||
(let [{color-value :value color-opacity :opacity} (-> grid :params :color)]
|
||||
(let [{color-value :value color-opacity :opacity} (-> grid :params :color)
|
||||
gutter (-> grid :params :gutter)
|
||||
gutter? (and (not (nil? gutter)) (not= gutter 0))
|
||||
|
||||
style (if gutter?
|
||||
#js {:fill color-value
|
||||
:opacity color-opacity}
|
||||
#js {:stroke color-value
|
||||
:strokeOpacity color-opacity
|
||||
:fill "transparent"})]
|
||||
[:g.grid
|
||||
(for [{:keys [x y width height]} (gg/grid-areas frame grid)]
|
||||
[:rect {:key (str key "-" x "-" y)
|
||||
|
@ -50,8 +59,7 @@
|
|||
:y y
|
||||
:width width
|
||||
:height height
|
||||
:style {:fill color-value
|
||||
:opacity color-opacity}}])]))
|
||||
:style style}])]))
|
||||
|
||||
(mf/defc grid-display-frame [{:keys [frame zoom]}]
|
||||
(let [grids (:grids frame)]
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
[{:keys [width height x y] :as frame} {:keys [size gutter margin item-length type] :as params}]
|
||||
(let [size (if (number? size) size (calculate-size width item-length margin gutter))
|
||||
parts (/ width size)
|
||||
item-width (or item-length (+ parts (- gutter) (/ gutter size) (- (/ (* margin 2) size))))
|
||||
item-width (min (or item-length ##Inf) (+ parts (- gutter) (/ gutter size) (- (/ (* margin 2) size))))
|
||||
item-height height
|
||||
initial-offset (case type
|
||||
:right (- width (* item-width size) (* gutter (dec size)) margin)
|
||||
|
@ -46,7 +46,7 @@
|
|||
(let [size (if (number? size) size (calculate-size height item-length margin gutter))
|
||||
parts (/ height size)
|
||||
item-width width
|
||||
item-height (or item-length (+ parts (- gutter) (/ gutter size) (- (/ (* margin 2) size))))
|
||||
item-height (min (or item-length ##Inf) (+ parts (- gutter) (/ gutter size) (- (/ (* margin 2) size))))
|
||||
initial-offset (case type
|
||||
:right (- height (* item-height size) (* gutter (dec size)) margin)
|
||||
:center (/ (- height (* item-height size) (* gutter (dec size))) 2)
|
||||
|
|
Loading…
Add table
Reference in a new issue