mirror of
https://github.com/penpot/penpot.git
synced 2025-12-11 22:14:05 +01:00
✨ Allow pass variant related attrs on add-component change
This commit is contained in:
@@ -320,14 +320,18 @@
|
|||||||
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
|
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
|
||||||
[:path {:optional true} :string]
|
[:path {:optional true} :string]
|
||||||
[:main-instance-id ::sm/uuid]
|
[:main-instance-id ::sm/uuid]
|
||||||
[:main-instance-page ::sm/uuid]]]
|
[:main-instance-page ::sm/uuid]
|
||||||
|
;; Only used by external processes (like Penpot SDK)
|
||||||
|
[:variant-id {:optional true} ::sm/uuid]
|
||||||
|
[:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]]
|
||||||
|
|
||||||
[:mod-component
|
[:mod-component
|
||||||
[:map {:title "ModCompoenentChange"}
|
[:map {:title "ModCompoenentChange"}
|
||||||
[:type [:= :mod-component]]
|
[:type [:= :mod-component]]
|
||||||
[:id ::sm/uuid]
|
[:id ::sm/uuid]
|
||||||
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
|
|
||||||
[:name {:optional true} :string]
|
[:name {:optional true} :string]
|
||||||
|
[:path {:optional true} :string]
|
||||||
|
[:shapes {:optional true} [:vector {:gen/max 3} ::sm/any]]
|
||||||
[:variant-id {:optional true} ::sm/uuid]
|
[:variant-id {:optional true} ::sm/uuid]
|
||||||
[:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]]
|
[:variant-properties {:optional true} [:vector ctv/schema:variant-property]]]]
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
|
|
||||||
(defn add-component
|
(defn add-component
|
||||||
[fdata {:keys [id name path main-instance-id main-instance-page annotation variant-id variant-properties]}]
|
[fdata {:keys [id name path main-instance-id main-instance-page annotation variant-id variant-properties]}]
|
||||||
(let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))]
|
(let [fdata (update fdata :components assoc id (touch {:id id :name name :path path}))]
|
||||||
(cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page)
|
(cond-> (update-in fdata [:components id] assoc :main-instance-id main-instance-id :main-instance-page main-instance-page)
|
||||||
annotation (update-in [:components id] assoc :annotation annotation)
|
annotation (update-in [:components id] assoc :annotation annotation)
|
||||||
variant-id (update-in [:components id] assoc :variant-id variant-id)
|
variant-id (update-in [:components id] assoc :variant-id variant-id)
|
||||||
@@ -83,9 +83,11 @@
|
|||||||
|
|
||||||
(nil? variant-properties)
|
(nil? variant-properties)
|
||||||
(dissoc :variant-properties))
|
(dissoc :variant-properties))
|
||||||
|
|
||||||
|
;; The set of properties that doesn't mark a component as touched
|
||||||
diff (set/difference
|
diff (set/difference
|
||||||
(ctk/diff-components component new-comp)
|
(ctk/diff-components component new-comp)
|
||||||
#{:annotation :modified-at :variant-id :variant-properties})] ;; The set of properties that doesn't mark a component as touched
|
#{:annotation :modified-at :variant-id :variant-properties})]
|
||||||
|
|
||||||
(if (empty? diff)
|
(if (empty? diff)
|
||||||
new-comp
|
new-comp
|
||||||
|
|||||||
Reference in New Issue
Block a user