mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 02:28:18 -05:00
🐛 Rework svg export of deleted components
This commit is contained in:
parent
3b5b81b08f
commit
6aeb87a122
2 changed files with 17 additions and 12 deletions
|
@ -23,6 +23,7 @@
|
|||
[app.common.geom.shapes.bounds :as gsb]
|
||||
[app.common.logging :as l]
|
||||
[app.common.math :as mth]
|
||||
[app.common.types.components-list :as ctkl]
|
||||
[app.common.types.file :as ctf]
|
||||
[app.common.types.modifiers :as ctm]
|
||||
[app.common.types.shape-tree :as ctst]
|
||||
|
@ -525,8 +526,10 @@
|
|||
|
||||
(mf/defc components-svg
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [data children embed include-metadata source]}]
|
||||
(let [source (keyword (d/nilv source "components"))]
|
||||
[{:keys [data children embed include-metadata deleted?]}]
|
||||
(let [components (if (not deleted?)
|
||||
(ctkl/components-seq data)
|
||||
(ctkl/deleted-components-seq data))]
|
||||
[:& (mf/provider embed/context) {:value embed}
|
||||
[:& (mf/provider export/include-metadata-ctx) {:value include-metadata}
|
||||
[:svg {:version "1.1"
|
||||
|
@ -536,9 +539,9 @@
|
|||
:style {:display (when-not (some? children) "none")}
|
||||
:fill "none"}
|
||||
[:defs
|
||||
(for [[id component] (source data)]
|
||||
(for [component components]
|
||||
(let [component (ctf/load-component-objects data component)]
|
||||
[:& component-symbol {:key (dm/str id) :component component}]))]
|
||||
[:& component-symbol {:key (dm/str (:id component)) :component component}]))]
|
||||
|
||||
children]]]))
|
||||
|
||||
|
@ -595,10 +598,12 @@
|
|||
(rds/renderToStaticMarkup elem)))))))
|
||||
|
||||
(defn render-components
|
||||
[data source]
|
||||
[data deleted?]
|
||||
(let [;; Join all components objects into a single map
|
||||
objects (->> (source data)
|
||||
(vals)
|
||||
components (if (not deleted?)
|
||||
(ctkl/components-seq data)
|
||||
(ctkl/deleted-components-seq data))
|
||||
objects (->> components
|
||||
(map (partial ctf/load-component-objects data))
|
||||
(map :objects)
|
||||
(reduce conj))]
|
||||
|
@ -615,7 +620,7 @@
|
|||
#js {:data data
|
||||
:embed true
|
||||
:include-metadata true
|
||||
:source (name source)})]
|
||||
:deleted? deleted?})]
|
||||
(rds/renderToStaticMarkup elem))))))))
|
||||
|
||||
(defn render-frame
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
:libraries (->> (:libraries file) (into #{}) (mapv str))
|
||||
:exportType (d/name export-type)
|
||||
:hasComponents (d/not-empty? (ctkl/components-seq (:data file)))
|
||||
:hasDeletedComponents (d/not-empty? (get-in file [:data :deleted-components]))
|
||||
:hasDeletedComponents (d/not-empty? (ctkl/deleted-components-seq (:data file)))
|
||||
:hasMedia (d/not-empty? (get-in file [:data :media]))
|
||||
:hasColors (d/not-empty? (get-in file [:data :colors]))
|
||||
:hasTypographies (d/not-empty? (get-in file [:data :typographies]))}))))]
|
||||
|
@ -151,12 +151,12 @@
|
|||
|
||||
(defn parse-library-components
|
||||
[file]
|
||||
(->> (r/render-components (:data file) :components)
|
||||
(->> (r/render-components (:data file) false)
|
||||
(rx/map #(vector (str (:id file) "/components.svg") %))))
|
||||
|
||||
(defn parse-deleted-components
|
||||
[file]
|
||||
(->> (r/render-components (:data file) :deleted-components)
|
||||
(->> (r/render-components (:data file) true)
|
||||
(rx/map #(vector (str (:id file) "/deleted-components.svg") %))))
|
||||
|
||||
(defn fetch-file-with-libraries
|
||||
|
@ -380,7 +380,7 @@
|
|||
deleted-components-stream
|
||||
(->> files-stream
|
||||
(rx/merge-map vals)
|
||||
(rx/filter #(d/not-empty? (get-in % [:data :deleted-components])))
|
||||
(rx/filter #(d/not-empty? (ctkl/deleted-components-seq (:data %))))
|
||||
(rx/merge-map parse-deleted-components))
|
||||
|
||||
pages-stream
|
||||
|
|
Loading…
Add table
Reference in a new issue