From 337e1c9fa0ef8319eae4acd718310d371977be96 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Thu, 18 Jul 2024 23:13:51 +0530 Subject: [PATCH 1/2] Fix application crashing when stroke width is applied to a shape without a stroke --- frontend/src/app/main/ui/workspace/tokens/core.cljs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/core.cljs b/frontend/src/app/main/ui/workspace/tokens/core.cljs index cb03a7a27..93e367a8a 100644 --- a/frontend/src/app/main/ui/workspace/tokens/core.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/core.cljs @@ -72,8 +72,9 @@ (defn update-stroke-width [value shape-ids] (dch/update-shapes shape-ids (fn [shape] - (when (seq (:strokes shape)) - (assoc-in shape [:strokes 0 :stroke-width] value))))) + (if (seq (:strokes shape)) + (assoc-in shape [:strokes 0 :stroke-width] value) + shape)))) (defn update-rotation [value shape-ids] (ptk/reify ::update-shape-dimensions From cb051d2e5b4a21df2bde8d7d9b02e6a467c94f78 Mon Sep 17 00:00:00 2001 From: Akshay Gupta Date: Fri, 19 Jul 2024 00:28:00 +0530 Subject: [PATCH 2/2] Fix app crashing when spacing padding is applied to a shape without a layout --- .../main/ui/workspace/tokens/context_menu.cljs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs index 352268480..803613ea9 100644 --- a/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs +++ b/frontend/src/app/main/ui/workspace/tokens/context_menu.cljs @@ -138,19 +138,23 @@ :token-type-props updated-token-type-props :selected-shapes selected-shapes}))) -(defn update-layout-spacing [value shape-ids attributes] - (if-let [layout-gap (cond - (:row-gap attributes) {:row-gap value} - (:column-gap attributes) {:column-gap value})] - (st/emit! (dwsl/update-layout shape-ids {:layout-gap layout-gap})) - (st/emit! (dwsl/update-layout shape-ids {:layout-padding (zipmap attributes (repeat value))})))) +(defn update-layout-spacing [value selected-shapes attributes] + (doseq [shape selected-shapes] + (let [shape-id (:id shape)] + (if-let [layout-gap (cond + (:row-gap attributes) {:row-gap value} + (:column-gap attributes) {:column-gap value})] + (st/emit! (dwsl/update-layout [shape-id] {:layout-gap layout-gap})) + (when (:layout shape) + (st/emit! (dwsl/update-layout [shape-id] {:layout-padding (zipmap attributes (repeat value))}))))))) (defn apply-spacing-token [{:keys [token-id token-type-props selected-shapes]} attributes] (let [token (dt/get-token-data-from-token-id token-id) attributes (set attributes) updated-token-type-props (assoc token-type-props - :on-update-shape update-layout-spacing + :on-update-shape (fn [value shape-ids] + (update-layout-spacing value selected-shapes attributes)) :attributes attributes)] (wtc/on-apply-token {:token token :token-type-props updated-token-type-props