mirror of
https://github.com/penpot/penpot.git
synced 2025-06-01 14:41:40 +02:00
♻️ Add a tool to generate swap-slots
This commit is contained in:
parent
a6f70c77cb
commit
2247f0ecac
3 changed files with 116 additions and 8 deletions
|
@ -90,6 +90,10 @@
|
|||
[container shape-id f]
|
||||
(update-in container [:objects shape-id] f))
|
||||
|
||||
(defn get-container-root
|
||||
[container]
|
||||
(d/seek #(or (nil? (:parent-id %)) (= (:parent-id %) uuid/zero)) (shapes-seq container)))
|
||||
|
||||
(defn get-direct-children
|
||||
[container shape]
|
||||
(map #(get-shape container %) (:shapes shape)))
|
||||
|
@ -107,7 +111,7 @@
|
|||
(get-children-rec [] id)))
|
||||
|
||||
(defn get-component-shape
|
||||
"Get the parent top shape linked to a component for this shape, if any"
|
||||
"Get the parent top shape linked to a component main for this shape, if any"
|
||||
([objects shape] (get-component-shape objects shape nil))
|
||||
([objects shape {:keys [allow-main?] :or {allow-main? false} :as options}]
|
||||
(let [parent (get objects (:parent-id shape))]
|
||||
|
|
|
@ -147,7 +147,7 @@
|
|||
|
||||
(defn get-component-container
|
||||
"Retrieve the container that holds the component shapes (the page in components-v2
|
||||
or the component itself in v1)"
|
||||
or the component itself in v1 or deleted component)."
|
||||
[file-data component]
|
||||
(let [components-v2 (dm/get-in file-data [:options :components-v2])]
|
||||
(if (and components-v2 (not (:deleted component)))
|
||||
|
@ -182,11 +182,12 @@
|
|||
:data file-data}
|
||||
:container (ctn/make-container component-page :page)})))))
|
||||
|
||||
(cond-> (dm/get-in component [:objects shape-id])
|
||||
with-context?
|
||||
(with-meta {:file {:id (:id file-data)
|
||||
:data file-data}
|
||||
:container (ctn/make-container component :component)})))))
|
||||
(let [shape (dm/get-in component [:objects shape-id])]
|
||||
(cond-> shape
|
||||
(and shape with-context?)
|
||||
(with-meta {:file {:id (:id file-data)
|
||||
:data file-data}
|
||||
:container (ctn/make-container component :component)}))))))
|
||||
|
||||
(defn get-ref-shape
|
||||
"Retrieve the shape in the component that is referenced by the instance shape."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue