mirror of
https://github.com/penpot/penpot.git
synced 2025-01-08 07:50:43 -05:00
commit
311a609977
4 changed files with 43 additions and 28 deletions
|
@ -383,13 +383,16 @@
|
|||
(update :svg-attrs dissoc :fill)
|
||||
(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-in [:svg-attrs :style] dissoc :fillOpacity)
|
||||
(assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :fillOpacity])
|
||||
(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 :svg-attrs dissoc :fillOpacity)
|
||||
(assoc-in [:fills 0 :fill-opacity] (-> (dm/get-in shape [:svg-attrs :style :fillOpacity])
|
||||
|
|
|
@ -62,32 +62,34 @@
|
|||
(obj/merge! props (get-border-props shape)))
|
||||
|
||||
(defn add-fill!
|
||||
[attrs fill-data render-id index type]
|
||||
(let [index (if (some? index) (dm/str "-" index) "")]
|
||||
(cond
|
||||
(contains? fill-data :fill-image)
|
||||
(let [id (dm/str "fill-image-" render-id)]
|
||||
(obj/set! attrs "fill" (dm/str "url(#" id ")")))
|
||||
([attrs fill-data render-id index type]
|
||||
(add-fill! attrs fill-data render-id index type "none"))
|
||||
([attrs fill-data render-id index type fill-default]
|
||||
(let [index (if (some? index) (dm/str "-" index) "")]
|
||||
(cond
|
||||
(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))
|
||||
(let [id (dm/str "fill-color-gradient-" render-id index)]
|
||||
(obj/set! attrs "fill" (dm/str "url(#" id ")")))
|
||||
(some? (:fill-color-gradient fill-data))
|
||||
(let [id (dm/str "fill-color-gradient-" render-id index)]
|
||||
(obj/set! attrs "fill" (dm/str "url(#" id ")")))
|
||||
|
||||
(contains? fill-data :fill-color)
|
||||
(obj/set! attrs "fill" (:fill-color fill-data))
|
||||
(contains? fill-data :fill-color)
|
||||
(obj/set! attrs "fill" (:fill-color fill-data))
|
||||
|
||||
:else
|
||||
(obj/set! attrs "fill" "none"))
|
||||
:else
|
||||
(obj/set! attrs "fill" fill-default))
|
||||
|
||||
(when (contains? fill-data :fill-opacity)
|
||||
(obj/set! attrs "fillOpacity" (:fill-opacity fill-data)))
|
||||
(when (contains? fill-data :fill-opacity)
|
||||
(obj/set! attrs "fillOpacity" (:fill-opacity fill-data)))
|
||||
|
||||
(when (and (= :text type)
|
||||
(nil? (:fill-color-gradient fill-data))
|
||||
(nil? (:fill-color fill-data)))
|
||||
(obj/set! attrs "fill" "black"))
|
||||
(when (and (= :text type)
|
||||
(nil? (:fill-color-gradient fill-data))
|
||||
(nil? (:fill-color fill-data)))
|
||||
(obj/set! attrs "fill" "black"))
|
||||
|
||||
attrs))
|
||||
attrs)))
|
||||
|
||||
(defn add-stroke!
|
||||
[attrs data render-id index open-path?]
|
||||
|
@ -165,8 +167,10 @@
|
|||
(obj/map->obj)))))
|
||||
|
||||
(defn get-fill-style
|
||||
[fill-data index render-id type]
|
||||
(add-fill! #js {} fill-data render-id index type))
|
||||
([fill-data index render-id 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!
|
||||
([props shape render-id]
|
||||
|
@ -242,8 +246,10 @@
|
|||
(obj/set! style "fillOpacity" opacity)))
|
||||
|
||||
^boolean (d/not-empty? shape-fills)
|
||||
(let [fill (nth shape-fills 0)]
|
||||
(obj/merge! style (get-fill-style fill render-id 0 shape-type)))
|
||||
(let [fill (nth shape-fills 0)
|
||||
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)
|
||||
^boolean (empty? shape-fills))
|
||||
|
|
|
@ -476,7 +476,8 @@
|
|||
svg-attrs (attrs/get-svg-props shape render-id)
|
||||
|
||||
style (-> (obj/get props "style")
|
||||
(obj/clone))
|
||||
(obj/clone)
|
||||
(obj/merge! (obj/get svg-attrs "style")))
|
||||
|
||||
props (mf/spread-props svg-attrs
|
||||
{:id stroke-id
|
||||
|
|
|
@ -11,7 +11,10 @@
|
|||
[app.common.geom.point :as gpt]
|
||||
[app.main.store :as st]
|
||||
[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 current-observer (atom nil))
|
||||
|
@ -45,6 +48,8 @@
|
|||
#(fn [node]
|
||||
(mf/set-ref-val! 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)))]))
|
||||
|
||||
(defn point->viewport
|
||||
|
|
Loading…
Reference in a new issue