mirror of
https://github.com/penpot/penpot.git
synced 2026-09-11 14:39:35 +00:00
🐛 Fix return type for combineAsVariants methods
This commit is contained in:
parent
a7e3d7963a
commit
6e03a191a3
@ -646,9 +646,11 @@
|
|||||||
component (u/locate-library-component file-id (:component-id shape))]
|
component (u/locate-library-component file-id (:component-id shape))]
|
||||||
(not (ctk/is-variant? component))))
|
(not (ctk/is-variant? component))))
|
||||||
ids)]
|
ids)]
|
||||||
(when valid?
|
(if valid?
|
||||||
(let [variant-id (uuid/next)]
|
(let [variant-id (uuid/next)]
|
||||||
(st/emit! (dwv/combine-as-variants
|
(st/emit! (dwv/combine-as-variants
|
||||||
ids
|
ids
|
||||||
{:trigger "plugin:combine-as-variants" :variant-id variant-id}))
|
{: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)
|
(u/not-valid plugin-id :ids ids)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [shape (u/locate-shape file-id page-id id)
|
(let [ids (->> ids
|
||||||
component (u/locate-library-component file-id (:component-id shape))
|
|
||||||
ids (->> ids
|
|
||||||
(map uuid/uuid)
|
(map uuid/uuid)
|
||||||
(into #{id}))]
|
(into #{id}))
|
||||||
(when (and component (not (ctk/is-variant? component)))
|
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)]
|
(let [variant-id (uuid/next)]
|
||||||
(st/emit! (dwv/combine-as-variants
|
(st/emit! (dwv/combine-as-variants
|
||||||
ids
|
ids
|
||||||
{:trigger "plugin:combine-as-variants" :variant-id variant-id}))
|
{: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))
|
(cond-> (or (cfh/frame-shape? data) (cfh/group-shape? data) (cfh/svg-raw-shape? data) (cfh/bool-shape? data))
|
||||||
(crc/add-properties!
|
(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));
|
console.log("Will define PENPOT_MCP_WEBSOCKET_URL as:", JSON.stringify(WS_URI));
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
base: "./",
|
base: "./",
|
||||||
plugins: [
|
plugins: [
|
||||||
livePreview({
|
livePreview({
|
||||||
reload: true,
|
reload: true,
|
||||||
config: {
|
config: {
|
||||||
build: {
|
build: {
|
||||||
|
|||||||
@ -304,7 +304,6 @@ Properties are often addressed positionally: `pos` parameter in various methods
|
|||||||
**Creating a variant group**:
|
**Creating a variant group**:
|
||||||
- `penpot.createVariantFromComponents(mainInstances: Board[]): VariantContainer`: Combines several main component instances into a new 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.
|
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.
|
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)`.
|
- After creation, edit properties using `variants.renameProperty(pos, name)`, `variants.addProperty()`, and `comp.setVariantProperty(pos, value)`.
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user