From a43d439b31998247549a3609cc8ea7635fdc81f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 8 Jun 2023 12:25:55 +0200 Subject: [PATCH] :bug: Revert #9de962bb and solve the fill issues in a different way --- frontend/src/app/main/ui/shapes/attrs.cljs | 9 +++++++-- .../src/app/main/ui/shapes/custom_stroke.cljs | 15 ++++++--------- frontend/src/app/main/ui/shapes/frame.cljs | 5 ++++- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/attrs.cljs b/frontend/src/app/main/ui/shapes/attrs.cljs index 59ab361a5..d736e2cf4 100644 --- a/frontend/src/app/main/ui/shapes/attrs.cljs +++ b/frontend/src/app/main/ui/shapes/attrs.cljs @@ -194,8 +194,13 @@ (obj/set! "fill" (obj/get svg-attrs "fill")) (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 black + ;; If the shape comes from an imported SVG (we know because it has + ;; the :svg-attrs atribute), and it does not have an own fill, we + ;; set a default black fill. This will be inherited by child nodes, + ;; and is for emulating the behavior of standard SVG, in that a node + ;; that has no explicit fill has a default fill of black. + ;; This may be reset to normal if a Penpot frame shape appears below + ;; (see main.ui.shapes.frame/frame-container). (and (contains? shape :svg-attrs) (#{:svg-raw :group} (:type shape)) (empty? (:fills shape))) diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 43b2af476..a7b1425de 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -370,9 +370,7 @@ (-> props (obj/set! "style" style))) - (and (some? svg-attrs) - (obj/contains? svg-attrs "fill") - (empty? (:fills shape))) + (and (some? svg-attrs) (empty? (:fills shape))) (let [style (-> (obj/get child "props") (obj/get "style") @@ -407,7 +405,7 @@ (obj/set! "style" style))) :else - nil))) + (obj/create)))) (defn build-stroke-props [position child value render-id] (let [props (-> (obj/get child "props") @@ -430,11 +428,10 @@ position (or (obj/get props "position") 0) render-id (or (obj/get props "render-id") (mf/use-ctx muc/render-id)) fill-props (build-fill-props shape child position render-id)] - (when (some? fill-props) - [:g.fills {:id (dm/fmt "fills-%" (:id shape))} - [:> elem-name (-> (obj/get child "props") - (obj/clone) - (obj/merge! fill-props))]]))) + [:g.fills {:id (dm/fmt "fills-%" (:id shape))} + [:> elem-name (-> (obj/get child "props") + (obj/clone) + (obj/merge! fill-props))]])) (mf/defc shape-strokes {::mf/wrap-props false} diff --git a/frontend/src/app/main/ui/shapes/frame.cljs b/frontend/src/app/main/ui/shapes/frame.cljs index 61afbb1ad..8a71a26ac 100644 --- a/frontend/src/app/main/ui/shapes/frame.cljs +++ b/frontend/src/app/main/ui/shapes/frame.cljs @@ -69,7 +69,10 @@ :className "frame-background"})) path? (some? (.-d props))] [:* - [:g {:clip-path (when (not show-content) (frame-clip-url shape render-id))} + [:g {:clip-path (when (not show-content) (frame-clip-url shape render-id)) + :fill "none"} ;; A frame sets back normal fill behavior (default transparent). It may have + ;; been changed to default black if a shape coming from an imported SVG file + ;; is rendered. See main.ui.shapes.attrs/add-style-attrs. [:& frame-clip-def {:shape shape :render-id render-id}] [:& shape-fills {:shape shape}