mirror of
https://github.com/penpot/penpot.git
synced 2026-03-29 15:52:17 +02:00
🐛 Fix return type for combineAsVariants methods
This commit is contained in:
committed by
Alonso Torres
parent
a7e3d7963a
commit
6e03a191a3
@@ -646,9 +646,11 @@
|
||||
component (u/locate-library-component file-id (:component-id shape))]
|
||||
(not (ctk/is-variant? component))))
|
||||
ids)]
|
||||
(when valid?
|
||||
(if valid?
|
||||
(let [variant-id (uuid/next)]
|
||||
(st/emit! (dwv/combine-as-variants
|
||||
ids
|
||||
{:trigger "plugin:combine-as-variants" :variant-id variant-id}))
|
||||
(library/variant-proxy plugin-id file-id variant-id))))))))
|
||||
(shape/shape-proxy plugin-id variant-id))
|
||||
|
||||
(u/not-valid plugin-id :shapes "One of the components is not on the same page or is already a variant")))))))
|
||||
|
||||
@@ -1383,17 +1383,25 @@
|
||||
(u/not-valid plugin-id :ids ids)
|
||||
|
||||
:else
|
||||
(let [shape (u/locate-shape file-id page-id id)
|
||||
component (u/locate-library-component file-id (:component-id shape))
|
||||
ids (->> ids
|
||||
(let [ids (->> ids
|
||||
(map uuid/uuid)
|
||||
(into #{id}))]
|
||||
(when (and component (not (ctk/is-variant? component)))
|
||||
(into #{id}))
|
||||
valid?
|
||||
(every?
|
||||
(fn [id]
|
||||
(let [shape (u/locate-shape file-id page-id id)
|
||||
component (u/locate-library-component file-id (:component-id shape))]
|
||||
(not (ctk/is-variant? component))))
|
||||
ids)]
|
||||
|
||||
(if valid?
|
||||
(let [variant-id (uuid/next)]
|
||||
(st/emit! (dwv/combine-as-variants
|
||||
ids
|
||||
{:trigger "plugin:combine-as-variants" :variant-id variant-id}))
|
||||
(variant-proxy plugin-id file-id variant-id)))))))
|
||||
(shape-proxy plugin-id variant-id))
|
||||
|
||||
(u/not-valid plugin-id :ids "One of the components is not on the same page or is already a variant"))))))
|
||||
|
||||
(cond-> (or (cfh/frame-shape? data) (cfh/group-shape? data) (cfh/svg-raw-shape? data) (cfh/bool-shape? data))
|
||||
(crc/add-properties!
|
||||
|
||||
@@ -7,9 +7,9 @@ let SERVER_HOST = process.env.PENPOT_MCP_PLUGIN_SERVER_HOST ?? "localhost";
|
||||
console.log("Will define PENPOT_MCP_WEBSOCKET_URL as:", JSON.stringify(WS_URI));
|
||||
|
||||
export default defineConfig({
|
||||
base: "./",
|
||||
plugins: [
|
||||
livePreview({
|
||||
base: "./",
|
||||
plugins: [
|
||||
livePreview({
|
||||
reload: true,
|
||||
config: {
|
||||
build: {
|
||||
|
||||
@@ -304,7 +304,6 @@ Properties are often addressed positionally: `pos` parameter in various methods
|
||||
**Creating a variant group**:
|
||||
- `penpot.createVariantFromComponents(mainInstances: Board[]): VariantContainer`: Combines several main component instances into a new variant group.
|
||||
All components end up inside a single new container on the canvas.
|
||||
NOTE: The returned instance `variantContainer` is not usable but has an usable id; use `penpot.findShapeById(variantContainer.id)` to get the actual instance you can work with.
|
||||
The container's `Variants` instance is initialised with one property `Property 1`, with the property values set to the respective component's name.
|
||||
- After creation, edit properties using `variants.renameProperty(pos, name)`, `variants.addProperty()`, and `comp.setVariantProperty(pos, value)`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user