mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
✨ Rename render-ctx to render-id
This commit is contained in:
parent
082bcd2bde
commit
3e3a10b5dd
10 changed files with 19 additions and 19 deletions
|
@ -8,7 +8,7 @@
|
||||||
(:require
|
(:require
|
||||||
[rumext.alpha :as mf]))
|
[rumext.alpha :as mf]))
|
||||||
|
|
||||||
(def render-ctx (mf/create-context nil))
|
(def render-id (mf/create-context nil))
|
||||||
|
|
||||||
(def current-route (mf/create-context nil))
|
(def current-route (mf/create-context nil))
|
||||||
(def current-profile (mf/create-context nil))
|
(def current-profile (mf/create-context nil))
|
||||||
|
|
|
@ -159,7 +159,7 @@
|
||||||
|
|
||||||
(defn add-style-attrs
|
(defn add-style-attrs
|
||||||
([props shape]
|
([props shape]
|
||||||
(let [render-id (mf/use-ctx muc/render-ctx)]
|
(let [render-id (mf/use-ctx muc/render-id)]
|
||||||
(add-style-attrs props shape render-id)))
|
(add-style-attrs props shape render-id)))
|
||||||
|
|
||||||
([props shape render-id]
|
([props shape render-id]
|
||||||
|
|
|
@ -211,7 +211,7 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
|
|
||||||
(let [render-id (mf/use-ctx muc/render-ctx)
|
(let [render-id (mf/use-ctx muc/render-id)
|
||||||
child (obj/get props "children")
|
child (obj/get props "children")
|
||||||
base-props (obj/get child "props")
|
base-props (obj/get child "props")
|
||||||
elem-name (obj/get child "type")
|
elem-name (obj/get child "type")
|
||||||
|
@ -253,7 +253,7 @@
|
||||||
(mf/defc inner-stroke
|
(mf/defc inner-stroke
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [render-id (mf/use-ctx muc/render-ctx)
|
(let [render-id (mf/use-ctx muc/render-id)
|
||||||
child (obj/get props "children")
|
child (obj/get props "children")
|
||||||
base-props (obj/get child "props")
|
base-props (obj/get child "props")
|
||||||
elem-name (obj/get child "type")
|
elem-name (obj/get child "type")
|
||||||
|
@ -292,7 +292,7 @@
|
||||||
|
|
||||||
(let [child (obj/get props "children")
|
(let [child (obj/get props "children")
|
||||||
shape (obj/get props "shape")
|
shape (obj/get props "shape")
|
||||||
render-id (mf/use-ctx muc/render-ctx)
|
render-id (mf/use-ctx muc/render-id)
|
||||||
index (obj/get props "index")
|
index (obj/get props "index")
|
||||||
stroke-width (:stroke-width shape 0)
|
stroke-width (:stroke-width shape 0)
|
||||||
stroke-style (:stroke-style shape :none)
|
stroke-style (:stroke-style shape :none)
|
||||||
|
@ -417,7 +417,7 @@
|
||||||
shape (obj/get props "shape")
|
shape (obj/get props "shape")
|
||||||
elem-name (obj/get child "type")
|
elem-name (obj/get child "type")
|
||||||
position (or (obj/get props "position") 0)
|
position (or (obj/get props "position") 0)
|
||||||
render-id (or (obj/get props "render-id") (mf/use-ctx muc/render-ctx))]
|
render-id (or (obj/get props "render-id") (mf/use-ctx muc/render-id))]
|
||||||
[:g {:id (dm/fmt "fills-%" (:id shape))}
|
[:g {:id (dm/fmt "fills-%" (:id shape))}
|
||||||
[:> elem-name (build-fill-props shape child position render-id)]]))
|
[:> elem-name (build-fill-props shape child position render-id)]]))
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@
|
||||||
(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 (or (obj/get props "render-id") (mf/use-ctx muc/render-ctx))
|
render-id (or (obj/get props "render-id") (mf/use-ctx muc/render-id))
|
||||||
stroke-id (dm/fmt "strokes-%" (:id shape))
|
stroke-id (dm/fmt "strokes-%" (:id shape))
|
||||||
stroke-props (-> (obj/create)
|
stroke-props (-> (obj/create)
|
||||||
(obj/set! "id" stroke-id)
|
(obj/set! "id" stroke-id)
|
||||||
|
|
|
@ -286,7 +286,7 @@
|
||||||
(for [[index fill] (d/enumerate fills)]
|
(for [[index fill] (d/enumerate fills)]
|
||||||
[:> "penpot:fill"
|
[:> "penpot:fill"
|
||||||
#js {:penpot:fill-color (if (some? (:fill-color-gradient fill))
|
#js {:penpot:fill-color (if (some? (:fill-color-gradient fill))
|
||||||
(str/format "url(#%s)" (str "fill-color-gradient_" (mf/use-ctx muc/render-ctx) "_" index))
|
(str/format "url(#%s)" (str "fill-color-gradient_" (mf/use-ctx muc/render-id) "_" index))
|
||||||
(d/name (:fill-color fill)))
|
(d/name (:fill-color fill)))
|
||||||
:penpot:fill-color-ref-file (d/name (:fill-color-ref-file fill))
|
:penpot:fill-color-ref-file (d/name (:fill-color-ref-file fill))
|
||||||
:penpot:fill-color-ref-id (d/name (:fill-color-ref-id fill))
|
:penpot:fill-color-ref-id (d/name (:fill-color-ref-id fill))
|
||||||
|
@ -299,7 +299,7 @@
|
||||||
(for [[index stroke] (d/enumerate strokes)]
|
(for [[index stroke] (d/enumerate strokes)]
|
||||||
[:> "penpot:stroke"
|
[:> "penpot:stroke"
|
||||||
#js {:penpot:stroke-color (if (some? (:stroke-color-gradient stroke))
|
#js {:penpot:stroke-color (if (some? (:stroke-color-gradient stroke))
|
||||||
(str/format "url(#%s)" (str "stroke-color-gradient_" (mf/use-ctx muc/render-ctx) "_" index))
|
(str/format "url(#%s)" (str "stroke-color-gradient_" (mf/use-ctx muc/render-id) "_" index))
|
||||||
(d/name (:stroke-color stroke)))
|
(d/name (:stroke-color stroke)))
|
||||||
:penpot:stroke-color-ref-file (d/name (:stroke-color-ref-file stroke))
|
:penpot:stroke-color-ref-file (d/name (:stroke-color-ref-file stroke))
|
||||||
:penpot:stroke-color-ref-id (d/name (:stroke-color-ref-id stroke))
|
:penpot:stroke-color-ref-id (d/name (:stroke-color-ref-id stroke))
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
:height height
|
:height height
|
||||||
:className "frame-background"}))
|
:className "frame-background"}))
|
||||||
path? (some? (.-d props))
|
path? (some? (.-d props))
|
||||||
render-id (mf/use-ctx muc/render-ctx)]
|
render-id (mf/use-ctx muc/render-id)]
|
||||||
|
|
||||||
[:*
|
[:*
|
||||||
[:g {:clip-path (when (not show-content) (frame-clip-url shape render-id))}
|
[:g {:clip-path (when (not show-content) (frame-clip-url shape render-id))}
|
||||||
|
|
|
@ -104,7 +104,7 @@
|
||||||
(let [attr (obj/get props "attr")
|
(let [attr (obj/get props "attr")
|
||||||
shape (obj/get props "shape")
|
shape (obj/get props "shape")
|
||||||
id (obj/get props "id")
|
id (obj/get props "id")
|
||||||
id' (mf/use-ctx muc/render-ctx)
|
id' (mf/use-ctx muc/render-id)
|
||||||
id (or id (dm/str (name attr) "_" id'))
|
id (or id (dm/str (name attr) "_" id'))
|
||||||
gradient (get shape attr)
|
gradient (get shape attr)
|
||||||
gradient-props #js {:id id
|
gradient-props #js {:id id
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
(let [shape (unchecked-get props "shape")
|
(let [shape (unchecked-get props "shape")
|
||||||
childs (unchecked-get props "childs")
|
childs (unchecked-get props "childs")
|
||||||
objects (unchecked-get props "objects")
|
objects (unchecked-get props "objects")
|
||||||
render-id (mf/use-ctx muc/render-ctx)
|
render-id (mf/use-ctx muc/render-id)
|
||||||
masked-group? (:masked-group? shape)
|
masked-group? (:masked-group? shape)
|
||||||
|
|
||||||
[mask childs] (if masked-group?
|
[mask childs] (if masked-group?
|
||||||
|
|
|
@ -47,18 +47,18 @@
|
||||||
{::mf/wrap-props false}
|
{::mf/wrap-props false}
|
||||||
[props]
|
[props]
|
||||||
(let [mask (unchecked-get props "mask")
|
(let [mask (unchecked-get props "mask")
|
||||||
render-id (mf/use-ctx muc/render-ctx)
|
render-id (mf/use-ctx muc/render-id)
|
||||||
svg-text? (and (= :text (:type mask)) (some? (:position-data mask)))
|
svg-text? (and (= :text (:type mask)) (some? (:position-data mask)))
|
||||||
|
|
||||||
;; This factory is generic, it's used for viewer, workspace and handoff.
|
;; This factory is generic, it's used for viewer, workspace and handoff.
|
||||||
;; These props are generated in viewer wrappers only, in the rest of the
|
;; These props are generated in viewer wrappers only, in the rest of the
|
||||||
;; cases these props will be nil, not affecting the code.
|
;; cases these props will be nil, not affecting the code.
|
||||||
fixed? (unchecked-get props "fixed?")
|
fixed? (unchecked-get props "fixed?")
|
||||||
delta (unchecked-get props "delta")
|
delta (unchecked-get props "delta")
|
||||||
mask-bb (-> (gsh/transform-shape mask)
|
mask-bb (-> (gsh/transform-shape mask)
|
||||||
(cond-> fixed? (gsh/move delta))
|
(cond-> fixed? (gsh/move delta))
|
||||||
(:points))
|
(:points))
|
||||||
|
|
||||||
mask-bb-rect (gsh/points->rect mask-bb)]
|
mask-bb-rect (gsh/points->rect mask-bb)]
|
||||||
[:defs
|
[:defs
|
||||||
[:filter {:id (filter-id render-id mask)}
|
[:filter {:id (filter-id render-id mask)}
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
svg-group?
|
svg-group?
|
||||||
(propagate-wrapper-styles wrapper-props))]
|
(propagate-wrapper-styles wrapper-props))]
|
||||||
|
|
||||||
[:& (mf/provider muc/render-ctx) {:value render-id}
|
[:& (mf/provider muc/render-id) {:value render-id}
|
||||||
[:> :g wrapper-props
|
[:> :g wrapper-props
|
||||||
(when include-metadata?
|
(when include-metadata?
|
||||||
[:& ed/export-data {:shape shape}])
|
[:& ed/export-data {:shape shape}])
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
::mf/wrap [mf/memo]}
|
::mf/wrap [mf/memo]}
|
||||||
[props]
|
[props]
|
||||||
|
|
||||||
(let [render-id (mf/use-ctx muc/render-ctx)
|
(let [render-id (mf/use-ctx muc/render-id)
|
||||||
shape (obj/get props "shape")
|
shape (obj/get props "shape")
|
||||||
shape (cond-> shape (:is-mask? shape) set-white-fill)
|
shape (cond-> shape (:is-mask? shape) set-white-fill)
|
||||||
|
|
||||||
|
@ -106,6 +106,6 @@
|
||||||
(obj/set! "fill" (str "url(#fill-" index "-" render-id ")")))})
|
(obj/set! "fill" (str "url(#fill-" index "-" render-id ")")))})
|
||||||
shape (assoc shape :fills (:fills data))]
|
shape (assoc shape :fills (:fills data))]
|
||||||
|
|
||||||
[:& (mf/provider muc/render-ctx) {:key index :value (str render-id "_" (:id shape) "_" index)}
|
[:& (mf/provider muc/render-id) {:key index :value (str render-id "_" (:id shape) "_" index)}
|
||||||
[:& shape-custom-strokes {:shape shape :position index :render-id render-id}
|
[:& shape-custom-strokes {:shape shape :position index :render-id render-id}
|
||||||
[:> :text props (:text data)]]]))]]))
|
[:> :text props (:text data)]]]))]]))
|
||||||
|
|
Loading…
Add table
Reference in a new issue