0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-26 08:29:42 -05:00

🐛 Fix issue with react hooks

This commit is contained in:
alonso.torres 2022-02-28 15:46:11 +01:00
parent 13af98e5ad
commit 52def43f5a
2 changed files with 14 additions and 14 deletions

View file

@ -233,9 +233,8 @@
(obj/set! "style" fill-styles)))) (obj/set! "style" fill-styles))))
(defn extract-stroke-attrs (defn extract-stroke-attrs
[shape index] [shape index render-id]
(let [render-id (mf/use-ctx muc/render-ctx) (let [stroke-styles (-> (obj/get shape "style" (obj/new))
stroke-styles (-> (obj/get shape "style" (obj/new))
(add-stroke shape render-id index))] (add-stroke shape render-id index))]
(-> (obj/new) (-> (obj/new)
(obj/set! "style" stroke-styles)))) (obj/set! "style" stroke-styles))))

View file

@ -316,9 +316,8 @@
[:& stroke-defs {:shape shape :render-id render-id :index index}]] [:& stroke-defs {:shape shape :render-id render-id :index index}]]
child]))) child])))
(defn build-stroke-props [position shape child value] (defn build-stroke-props [position shape child value render-id]
(let [render-id (mf/use-ctx muc/render-ctx) (let [url-fill? (or (some? (:fill-image shape))
url-fill? (or (some? (:fill-image shape))
(= :image (:type shape)) (= :image (:type shape))
(> (count (:fills shape)) 1) (> (count (:fills shape)) 1)
(some :fill-color-gradient (:fills shape))) (some :fill-color-gradient (:fills shape)))
@ -348,8 +347,7 @@
(obj/set! "fillOpacity" "none"))))) (obj/set! "fillOpacity" "none")))))
props (-> props props (-> props
(add-style (add-style (obj/get (attrs/extract-stroke-attrs value position render-id) "style")))]
(obj/get (attrs/extract-stroke-attrs value position) "style")))]
props)) props))
(mf/defc shape-custom-strokes (mf/defc shape-custom-strokes
@ -357,14 +355,17 @@
[props] [props]
(let [child (obj/get props "children") (let [child (obj/get props "children")
shape (obj/get props "shape") shape (obj/get props "shape")
elem-name (obj/get child "type")] elem-name (obj/get child "type")
render-id (mf/use-ctx muc/render-ctx)]
(cond (cond
(seq (:strokes shape)) (d/not-empty? (:strokes shape))
[:* [:*
(for [[index value] (-> (d/enumerate (:strokes shape)) reverse)] (for [[index value] (-> (d/enumerate (:strokes shape)) reverse)]
[:& shape-custom-stroke {:shape (assoc value :points (:points shape)) :index index} (let [props (build-stroke-props index shape child value render-id)
[:> elem-name (build-stroke-props index shape child value)]])] shape (assoc value :points (:points shape))]
[:& shape-custom-stroke {:shape shape :index index}
[:> elem-name props]]))]
:else :else
[:& shape-custom-stroke {:shape shape :index 0} [:& shape-custom-stroke {:shape shape :index 0}