♻️ Migrate shapes/export components to modern syntax (#9449)

* ♻️ Migrate shapes/export components to modern syntax

* 📎 Add minor changes

Signed-off-by: Andrey Antukh <niwi@niwi.nz>

* 📎 Remove whitespace

Signed-off-by: Andrey Antukh <niwi@niwi.nz>

---------

Signed-off-by: Andrey Antukh <niwi@niwi.nz>
Co-authored-by: Andrey Antukh <niwi@niwi.nz>
This commit is contained in:
Dexterity 2026-06-22 09:28:00 -04:00 committed by GitHub
parent 4bbf9a6617
commit 22cf4917d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 13 deletions

View File

@ -239,7 +239,7 @@
:fill "none"}
(when include-metadata
[:& export/export-page {:page data}])
[:> export/export-page* {:page data}])
(let [shapes (->> shapes
(remove cfh/frame-shape?)

View File

@ -24,7 +24,7 @@
(def include-metadata-ctx
(mf/create-context false))
(mf/defc render-xml
(mf/defc render-xml*
[{{:keys [tag attrs content] :as node} :xml}]
(cond
@ -33,7 +33,7 @@
(json/->js :key-fn name))]
[:> (d/name tag) props
(for [child content]
[:& render-xml {:xml child :key (swap! internal-counter inc)}])])
[:> render-xml* {:xml child :key (swap! internal-counter inc)}])])
(string? node)
node
@ -166,7 +166,7 @@
(cond-> (some? display)
(obj/set! "penpot:display" (str display))))]))])))
(mf/defc export-flows
(mf/defc export-flows*
[{:keys [flows]}]
[:> "penpot:flows" #js {}
(for [{:keys [id name starting-frame]} (vals flows)]
@ -175,7 +175,7 @@
:name name
:starting-frame starting-frame}])])
(mf/defc export-guides
(mf/defc export-guides*
[{:keys [guides]}]
[:> "penpot:guides" #js {}
(for [{:keys [position frame-id axis]} (vals guides)]
@ -183,8 +183,7 @@
:frame-id frame-id
:axis (d/name axis)}])])
(mf/defc export-page
{::mf/props :obj}
(mf/defc export-page*
[{:keys [page]}]
(let [id (get page :id)
grids (get page :grids)
@ -197,10 +196,10 @@
[:& export-grid-data {:grids grids}]))
(when (d/not-empty? flows)
[:& export-flows {:flows flows}])
[:> export-flows* {:flows flows}])
(when (d/not-empty? guides)
[:& export-guides {:guides guides}])]))
[:> export-guides* {:guides guides}])]))
(defn- export-shadow-data [{:keys [shadow]}]
(mf/html
@ -273,7 +272,7 @@
(for [[def-id def-xml] (:svg-defs shape)]
[:> "penpot:svg-def" #js {:def-id def-id
:key (swap! internal-counter inc)}
[:& render-xml {:xml def-xml}]])]))
[:> render-xml* {:xml def-xml}]])]))
(when (= (:type shape) :svg-raw)
(let [shape (-> shape (d/update-in-when [:content :attrs :style] str->style))
@ -478,7 +477,7 @@
:penpot:layout-item-z-index layout-item-z-index}])))
(mf/defc export-data
(mf/defc export-data*
[{:keys [shape]}]
(let [props (-> (obj/create) (add-data shape) (add-library-refs shape))]
[:> "penpot:shape" props

View File

@ -122,7 +122,7 @@
[:& (mf/provider muc/render-id) {:value render-id}
[:> :g wrapper-props
(when include-metadata?
[:& ed/export-data {:shape shape}])
[:> ed/export-data* {:shape shape}])
[:defs
[:> defs/svg-defs* {:shape shape :render-id render-id}]

View File

@ -398,7 +398,7 @@
[:stop {:offset "100%" :stop-color (str "color-mix(in srgb-linear, " background " 90%, #777)") :stop-opacity 1}]]]
(when (dbg/enabled? :show-export-metadata)
[:& use/export-page {:page page}])
[:> use/export-page* {:page page}])
;; We need a "real" background shape so layer transforms work properly in firefox
[:rect {:width (:width vbox 0)