From 8d399cb56285585e4d86f32d943f1dff235715fd Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Tue, 10 May 2022 08:15:45 +0200 Subject: [PATCH] :bug: Fix import svg shapes without fill --- frontend/src/app/main/ui/shapes/attrs.cljs | 6 +++-- .../src/app/main/ui/shapes/custom_stroke.cljs | 22 +++++++------------ 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index aeafe56b1..2346da674 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -6,6 +6,7 @@ (ns app.main.ui.shapes.attrs (:require + [app.common.colors :as clr] [app.common.data :as d] [app.common.data.macros :as dm] [app.common.geom.shapes :as gsh] @@ -186,11 +187,12 @@ (obj/set! "fillOpacity" (obj/get svg-attrs "fillOpacity"))) ;; If contains svg-attrs the origin is svg. If it's not svg origin - ;; we setup the default fill as transparent (instead of black) + ;; we setup the default fill as black (and (contains? shape :svg-attrs) (#{:svg-raw :group} (:type shape)) (empty? (:fills shape))) - styles + (-> styles + (obj/set! "fill" clr/black)) (d/not-empty? (:fills shape)) (add-fill styles (d/without-nils (get-in shape [:fills 0])) render-id 0) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index b124aca04..3f8bb272b 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -6,7 +6,6 @@ (ns app.main.ui.shapes.custom-stroke (:require - [app.common.colors :as clr] [app.common.data :as d] [app.common.data.macros :as dm] [app.common.geom.shapes :as gsh] @@ -361,16 +360,19 @@ (-> props (obj/set! "style" style))) - (and (some? svg-attrs) (obj/contains? svg-attrs "fill")) + (some? svg-attrs) (let [style (-> (obj/get props "style") - (obj/clone) - (obj/set! "fill" (obj/get svg-attrs "fill")) - (obj/set! "fillOpacity" (obj/get svg-attrs "fillOpacity")))] + (obj/clone)) + + style (cond-> style + (obj/contains? svg-attrs "fill") + (-> + (obj/set! "fill" (obj/get svg-attrs "fill")) + (obj/set! "fillOpacity" (obj/get svg-attrs "fillOpacity"))))] (-> props (obj/set! "style" style))) - (d/not-empty? (:fills shape)) (let [fill-props (attrs/extract-fill-attrs (get-in shape [:fills 0]) render-id 0) @@ -383,14 +385,6 @@ (some? style) (obj/set! "style" style))) - (some? (:svg-attrs shape)) - (let [style - (-> (obj/get props "style") - (obj/clone) - (obj/set! "fill" clr/black))] - (-> props - (obj/set! "style" style))) - (and (= :path (:type shape)) (empty? (:fills shape))) (let [style (-> (obj/get props "style")