From 0611ce98a377a2c26818a56a210ebe9dbde9d466 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Wed, 20 May 2020 15:37:11 +0200 Subject: [PATCH] :bug: Fixed some corner cases with grid parameters --- .../src/uxbox/main/ui/workspace/frame_grid.cljs | 14 +++++++++++--- frontend/src/uxbox/util/geom/grid.cljs | 4 ++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/uxbox/main/ui/workspace/frame_grid.cljs b/frontend/src/uxbox/main/ui/workspace/frame_grid.cljs index 1707d03a5..b8905b222 100644 --- a/frontend/src/uxbox/main/ui/workspace/frame_grid.cljs +++ b/frontend/src/uxbox/main/ui/workspace/frame_grid.cljs @@ -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)] diff --git a/frontend/src/uxbox/util/geom/grid.cljs b/frontend/src/uxbox/util/geom/grid.cljs index b3706e25a..f1143f192 100644 --- a/frontend/src/uxbox/util/geom/grid.cljs +++ b/frontend/src/uxbox/util/geom/grid.cljs @@ -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)