From 2b715851e187c36c3802cf31247a95783d136492 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 30 Jan 2024 16:00:22 +0100 Subject: [PATCH] :bug: Fix proportional scaling with grid layout --- common/src/app/common/types/modifiers.cljc | 3 +++ common/src/app/common/types/shape/layout.cljc | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/common/src/app/common/types/modifiers.cljc b/common/src/app/common/types/modifiers.cljc index 5b2b2fe5df..4d893118c5 100644 --- a/common/src/app/common/types/modifiers.cljc +++ b/common/src/app/common/types/modifiers.cljc @@ -756,6 +756,9 @@ (ctl/flex-layout? shape) (ctl/update-flex-scale value) + (ctl/grid-layout? shape) + (ctl/update-grid-scale value) + :always (ctl/update-flex-child value)))] diff --git a/common/src/app/common/types/shape/layout.cljc b/common/src/app/common/types/shape/layout.cljc index 104fb9bc71..823f57407c 100644 --- a/common/src/app/common/types/shape/layout.cljc +++ b/common/src/app/common/types/shape/layout.cljc @@ -601,6 +601,16 @@ (d/update-in-when [:layout-padding :p3] * scale) (d/update-in-when [:layout-padding :p4] * scale))) +(defn update-grid-scale + [shape scale] + (letfn [(scale-track [track] + (cond-> track + (= (:type track) :fixed) + (update :value * scale)))] + (-> shape + (update :layout-grid-columns #(mapv scale-track %)) + (update :layout-grid-rows #(mapv scale-track %))))) + (defn update-flex-child [shape scale] (-> shape