mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Assign correct fill to match standard svg behavior when no fils found
On parsing svg
This commit is contained in:
parent
63b264b494
commit
ad185c4215
2 changed files with 13 additions and 13 deletions
|
@ -229,6 +229,7 @@
|
||||||
:svg-viewbox selrect
|
:svg-viewbox selrect
|
||||||
:svg-attrs attrs
|
:svg-attrs attrs
|
||||||
:svg-transform transform
|
:svg-transform transform
|
||||||
|
:strokes []
|
||||||
:fills []})
|
:fills []})
|
||||||
(gsh/translate-to-frame origin)))))
|
(gsh/translate-to-frame origin)))))
|
||||||
|
|
||||||
|
@ -384,6 +385,7 @@
|
||||||
(update :svg-attrs dissoc :fillOpacity)
|
(update :svg-attrs dissoc :fillOpacity)
|
||||||
(assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :style :fillOpacity])
|
(assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :style :fillOpacity])
|
||||||
(d/parse-double 1)))))))
|
(d/parse-double 1)))))))
|
||||||
|
|
||||||
(defn- setup-stroke
|
(defn- setup-stroke
|
||||||
[shape]
|
[shape]
|
||||||
(let [attrs (get shape :svg-attrs)
|
(let [attrs (get shape :svg-attrs)
|
||||||
|
@ -422,7 +424,8 @@
|
||||||
(dissoc :stroke)
|
(dissoc :stroke)
|
||||||
(dissoc :strokeLinecap)
|
(dissoc :strokeLinecap)
|
||||||
(dissoc :strokeWidth)
|
(dissoc :strokeWidth)
|
||||||
(dissoc :strokeOpacity)))))]
|
(dissoc :strokeOpacity))))
|
||||||
|
(d/without-nils))]
|
||||||
|
|
||||||
(cond-> (assoc shape :svg-attrs attrs)
|
(cond-> (assoc shape :svg-attrs attrs)
|
||||||
(some? color)
|
(some? color)
|
||||||
|
@ -434,7 +437,7 @@
|
||||||
(and (some? color) (some? width))
|
(and (some? color) (some? width))
|
||||||
(assoc-in [:strokes 0 :stroke-width] 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)))
|
(or (= linecap :round) (= linecap :square)))
|
||||||
(assoc :stroke-cap-start linecap
|
(assoc :stroke-cap-start linecap
|
||||||
:stroke-cap-end linecap)
|
:stroke-cap-end linecap)
|
||||||
|
@ -464,9 +467,6 @@
|
||||||
(-> (update-in [:svg-attrs :style] dissoc :mixBlendMode)
|
(-> (update-in [:svg-attrs :style] dissoc :mixBlendMode)
|
||||||
(assoc :blend-mode (-> (dm/get-in shape [:svg-attrs :style :mixBlendMode]) assert-valid-blend-mode)))))
|
(assoc :blend-mode (-> (dm/get-in shape [:svg-attrs :style :mixBlendMode]) assert-valid-blend-mode)))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defn tag->name
|
(defn tag->name
|
||||||
"Given a tag returns its layer name"
|
"Given a tag returns its layer name"
|
||||||
[tag]
|
[tag]
|
||||||
|
|
|
@ -21,6 +21,9 @@
|
||||||
[cuerdas.core :as str]
|
[cuerdas.core :as str]
|
||||||
[rumext.v2 :as mf]))
|
[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/defc inner-stroke-clip-path
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[{:keys [shape render-id index]}]
|
[{:keys [shape render-id index]}]
|
||||||
|
@ -449,10 +452,8 @@
|
||||||
(obj/unset! style "fillOpacity")
|
(obj/unset! style "fillOpacity")
|
||||||
(obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id)))
|
(obj/set! props "fill" (dm/fmt "url(#fill-%-%)" position render-id)))
|
||||||
|
|
||||||
(and ^boolean (or (obj/contains? svg-styles "fill")
|
(and ^boolean (some? svg-styles)
|
||||||
(obj/contains? svg-styles "fillOpacity"))
|
|
||||||
^boolean (obj/contains? svg-styles "fill"))
|
^boolean (obj/contains? svg-styles "fill"))
|
||||||
|
|
||||||
(let [fill (obj/get svg-styles "fill")
|
(let [fill (obj/get svg-styles "fill")
|
||||||
opacity (obj/get svg-styles "fillOpacity")]
|
opacity (obj/get svg-styles "fillOpacity")]
|
||||||
(when (some? fill)
|
(when (some? fill)
|
||||||
|
@ -460,8 +461,7 @@
|
||||||
(when (some? opacity)
|
(when (some? opacity)
|
||||||
(obj/set! style "fillOpacity" opacity)))
|
(obj/set! style "fillOpacity" opacity)))
|
||||||
|
|
||||||
(and ^boolean (or (obj/contains? svg-attrs "fill")
|
(and ^boolean (some? svg-attrs)
|
||||||
(obj/contains? svg-attrs "fillOpacity"))
|
|
||||||
^boolean (empty? shape-fills))
|
^boolean (empty? shape-fills))
|
||||||
(let [fill (obj/get svg-attrs "fill")
|
(let [fill (obj/get svg-attrs "fill")
|
||||||
opacity (obj/get svg-attrs "fillOpacity")]
|
opacity (obj/get svg-attrs "fillOpacity")]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue