diff --git a/common/src/app/common/svg/shapes_builder.cljc b/common/src/app/common/svg/shapes_builder.cljc index 632b1483d..6cb5429aa 100644 --- a/common/src/app/common/svg/shapes_builder.cljc +++ b/common/src/app/common/svg/shapes_builder.cljc @@ -229,6 +229,7 @@ :svg-viewbox selrect :svg-attrs attrs :svg-transform transform + :strokes [] :fills []}) (gsh/translate-to-frame origin))))) @@ -355,9 +356,9 @@ (assoc :svg-attrs props)))))) (defn setup-fill - [shape] - (let [color-attr (str/trim (dm/get-in shape [:svg-attrs :fill])) - color-attr (if (= color-attr "currentColor") clr/black color-attr) + [shape] + (let [color-attr (str/trim (dm/get-in shape [:svg-attrs :fill])) + color-attr (if (= color-attr "currentColor") clr/black color-attr) color-style (str/trim (dm/get-in shape [:svg-attrs :style :fill])) color-style (if (= color-style "currentColor") clr/black color-style)] (cond-> shape @@ -384,6 +385,7 @@ (update :svg-attrs dissoc :fillOpacity) (assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :style :fillOpacity]) (d/parse-double 1))))))) + (defn- setup-stroke [shape] (let [attrs (get shape :svg-attrs) @@ -422,7 +424,8 @@ (dissoc :stroke) (dissoc :strokeLinecap) (dissoc :strokeWidth) - (dissoc :strokeOpacity)))))] + (dissoc :strokeOpacity)))) + (d/without-nils))] (cond-> (assoc shape :svg-attrs attrs) (some? color) @@ -434,7 +437,7 @@ (and (some? color) (some? width)) (assoc-in [:strokes 0 :stroke-width] width) - (and (some? linecap) (= (:type shape) :path) + (and (some? linecap) (cfh/path-shape? shape) (or (= linecap :round) (= linecap :square))) (assoc :stroke-cap-start linecap :stroke-cap-end linecap) @@ -464,9 +467,6 @@ (-> (update-in [:svg-attrs :style] dissoc :mixBlendMode) (assoc :blend-mode (-> (dm/get-in shape [:svg-attrs :style :mixBlendMode]) assert-valid-blend-mode))))) - - - (defn tag->name "Given a tag returns its layer name" [tag] diff --git a/frontend/src/app/main/ui/shapes/custom_stroke.cljs b/frontend/src/app/main/ui/shapes/custom_stroke.cljs index 205f83a6e..d8607f6b5 100644 --- a/frontend/src/app/main/ui/shapes/custom_stroke.cljs +++ b/frontend/src/app/main/ui/shapes/custom_stroke.cljs @@ -21,6 +21,9 @@ [cuerdas.core :as str] [rumext.v2 :as mf])) +;; FIXME: this clearly should be renamed to something different, this +;; namespace has also fill related code + (mf/defc inner-stroke-clip-path {::mf/wrap-props false} [{:keys [shape render-id index]}] @@ -449,10 +452,8 @@ (obj/unset! style "fillOpacity") (obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id))) - (and ^boolean (or (obj/contains? svg-styles "fill") - (obj/contains? svg-styles "fillOpacity")) + (and ^boolean (some? svg-styles) ^boolean (obj/contains? svg-styles "fill")) - (let [fill (obj/get svg-styles "fill") opacity (obj/get svg-styles "fillOpacity")] (when (some? fill) @@ -460,8 +461,7 @@ (when (some? opacity) (obj/set! style "fillOpacity" opacity))) - (and ^boolean (or (obj/contains? svg-attrs "fill") - (obj/contains? svg-attrs "fillOpacity")) + (and ^boolean (some? svg-attrs) ^boolean (empty? shape-fills)) (let [fill (obj/get svg-attrs "fill") opacity (obj/get svg-attrs "fillOpacity")]