0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-23 23:18:48 -05:00

Merge pull request #4290 from penpot/alotor-bugfix-32

Bugfix
This commit is contained in:
Alejandro 2024-03-19 11:53:29 +01:00 committed by GitHub
commit 311a609977
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 43 additions and 28 deletions

View file

@ -383,13 +383,16 @@
(update :svg-attrs dissoc :fill) (update :svg-attrs dissoc :fill)
(assoc-in [:fills 0 :fill-color] (clr/parse color-style))) (assoc-in [:fills 0 :fill-color] (clr/parse color-style)))
(dm/get-in shape [:svg-attrs :fillOpacity]) ;; Only create an opacity if the color is setted. Othewise can create problems down the line
(and (or (clr/color-string? color-attr) (clr/color-string? color-style))
(dm/get-in shape [:svg-attrs :fillOpacity]))
(-> (update :svg-attrs dissoc :fillOpacity) (-> (update :svg-attrs dissoc :fillOpacity)
(update-in [:svg-attrs :style] dissoc :fillOpacity) (update-in [:svg-attrs :style] dissoc :fillOpacity)
(assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :fillOpacity]) (assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :fillOpacity])
(d/parse-double 1)))) (d/parse-double 1))))
(dm/get-in shape [:svg-attrs :style :fillOpacity]) (and (or (clr/color-string? color-attr) (clr/color-string? color-style))
(dm/get-in shape [:svg-attrs :style :fillOpacity]))
(-> (update-in [:svg-attrs :style] dissoc :fillOpacity) (-> (update-in [:svg-attrs :style] dissoc :fillOpacity)
(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])

View file

@ -62,32 +62,34 @@
(obj/merge! props (get-border-props shape))) (obj/merge! props (get-border-props shape)))
(defn add-fill! (defn add-fill!
[attrs fill-data render-id index type] ([attrs fill-data render-id index type]
(let [index (if (some? index) (dm/str "-" index) "")] (add-fill! attrs fill-data render-id index type "none"))
(cond ([attrs fill-data render-id index type fill-default]
(contains? fill-data :fill-image) (let [index (if (some? index) (dm/str "-" index) "")]
(let [id (dm/str "fill-image-" render-id)] (cond
(obj/set! attrs "fill" (dm/str "url(#" id ")"))) (contains? fill-data :fill-image)
(let [id (dm/str "fill-image-" render-id)]
(obj/set! attrs "fill" (dm/str "url(#" id ")")))
(some? (:fill-color-gradient fill-data)) (some? (:fill-color-gradient fill-data))
(let [id (dm/str "fill-color-gradient-" render-id index)] (let [id (dm/str "fill-color-gradient-" render-id index)]
(obj/set! attrs "fill" (dm/str "url(#" id ")"))) (obj/set! attrs "fill" (dm/str "url(#" id ")")))
(contains? fill-data :fill-color) (contains? fill-data :fill-color)
(obj/set! attrs "fill" (:fill-color fill-data)) (obj/set! attrs "fill" (:fill-color fill-data))
:else :else
(obj/set! attrs "fill" "none")) (obj/set! attrs "fill" fill-default))
(when (contains? fill-data :fill-opacity) (when (contains? fill-data :fill-opacity)
(obj/set! attrs "fillOpacity" (:fill-opacity fill-data))) (obj/set! attrs "fillOpacity" (:fill-opacity fill-data)))
(when (and (= :text type) (when (and (= :text type)
(nil? (:fill-color-gradient fill-data)) (nil? (:fill-color-gradient fill-data))
(nil? (:fill-color fill-data))) (nil? (:fill-color fill-data)))
(obj/set! attrs "fill" "black")) (obj/set! attrs "fill" "black"))
attrs)) attrs)))
(defn add-stroke! (defn add-stroke!
[attrs data render-id index open-path?] [attrs data render-id index open-path?]
@ -165,8 +167,10 @@
(obj/map->obj))))) (obj/map->obj)))))
(defn get-fill-style (defn get-fill-style
[fill-data index render-id type] ([fill-data index render-id type]
(add-fill! #js {} fill-data render-id index type)) (add-fill! #js {} fill-data render-id index type))
([fill-data index render-id type fill-default]
(add-fill! #js {} fill-data render-id index type fill-default)))
(defn add-fill-props! (defn add-fill-props!
([props shape render-id] ([props shape render-id]
@ -242,8 +246,10 @@
(obj/set! style "fillOpacity" opacity))) (obj/set! style "fillOpacity" opacity)))
^boolean (d/not-empty? shape-fills) ^boolean (d/not-empty? shape-fills)
(let [fill (nth shape-fills 0)] (let [fill (nth shape-fills 0)
(obj/merge! style (get-fill-style fill render-id 0 shape-type))) svg-fill (obj/get svg-attrs "fill")
fill-default (d/nilv svg-fill "none")]
(obj/merge! style (get-fill-style fill render-id 0 shape-type fill-default)))
(and ^boolean (cfh/path-shape? shape) (and ^boolean (cfh/path-shape? shape)
^boolean (empty? shape-fills)) ^boolean (empty? shape-fills))

View file

@ -476,7 +476,8 @@
svg-attrs (attrs/get-svg-props shape render-id) svg-attrs (attrs/get-svg-props shape render-id)
style (-> (obj/get props "style") style (-> (obj/get props "style")
(obj/clone)) (obj/clone)
(obj/merge! (obj/get svg-attrs "style")))
props (mf/spread-props svg-attrs props (mf/spread-props svg-attrs
{:id stroke-id {:id stroke-id

View file

@ -11,7 +11,10 @@
[app.common.geom.point :as gpt] [app.common.geom.point :as gpt]
[app.main.store :as st] [app.main.store :as st]
[app.util.dom :as dom] [app.util.dom :as dom]
[rumext.v2 :as mf])) [app.util.mouse :as mse]
[goog.events :as events]
[rumext.v2 :as mf])
(:import goog.events.EventType))
(defonce viewport-ref (atom nil)) (defonce viewport-ref (atom nil))
(defonce current-observer (atom nil)) (defonce current-observer (atom nil))
@ -45,6 +48,8 @@
#(fn [node] #(fn [node]
(mf/set-ref-val! ref node) (mf/set-ref-val! ref node)
(reset! viewport-ref node) (reset! viewport-ref node)
(when (some? node)
(events/listen node EventType.MOUSEOUT (fn [] (st/emit! (mse/->BlurEvent)))))
(init-observer node on-change-bounds)))])) (init-observer node on-change-bounds)))]))
(defn point->viewport (defn point->viewport