mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 05:33:02 -05:00
Improve registering component properties (#201)
* improvements * changeset * fixes
This commit is contained in:
parent
7a11ba992e
commit
bd36496023
5 changed files with 24 additions and 21 deletions
5
.changeset/dirty-jobs-begin.md
Normal file
5
.changeset/dirty-jobs-begin.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"penpot-exporter": patch
|
||||
---
|
||||
|
||||
Improve registering component properties
|
13
plugin-src/registerComponentProperties.ts
Normal file
13
plugin-src/registerComponentProperties.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { componentProperties } from '@plugin/libraries';
|
||||
|
||||
export const registerComponentProperties = (node: ComponentSetNode | ComponentNode) => {
|
||||
try {
|
||||
Object.entries(node.componentPropertyDefinitions).forEach(([key, value]) => {
|
||||
if (value.type === 'TEXT' || value.type === 'BOOLEAN') {
|
||||
componentProperties.set(key, value);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error registering component properties', node, error);
|
||||
}
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { componentProperties, components } from '@plugin/libraries';
|
||||
import { components } from '@plugin/libraries';
|
||||
import { registerComponentProperties } from '@plugin/registerComponentProperties';
|
||||
import {
|
||||
transformAutoLayout,
|
||||
transformBlend,
|
||||
|
@ -45,15 +46,7 @@ export const transformComponentNode = async (node: ComponentNode): Promise<Compo
|
|||
});
|
||||
|
||||
if (isNonVariantComponentNode(node)) {
|
||||
try {
|
||||
Object.entries(node.componentPropertyDefinitions).forEach(([key, value]) => {
|
||||
if (value.type === 'TEXT' || value.type === 'BOOLEAN') {
|
||||
componentProperties.set(key, value);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error registering component properties', error);
|
||||
}
|
||||
registerComponentProperties(node);
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { componentProperties } from '@plugin/libraries';
|
||||
import { registerComponentProperties } from '@plugin/registerComponentProperties';
|
||||
import {
|
||||
transformAutoLayout,
|
||||
transformBlend,
|
||||
|
@ -37,15 +37,7 @@ export const transformFrameNode = async (
|
|||
let referencePoint: Point = { x: node.absoluteTransform[0][2], y: node.absoluteTransform[1][2] };
|
||||
|
||||
if (isComponentSetNode(node)) {
|
||||
try {
|
||||
Object.entries(node.componentPropertyDefinitions).forEach(([key, value]) => {
|
||||
if (value.type === 'TEXT' || value.type === 'BOOLEAN') {
|
||||
componentProperties.set(key, value);
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error registering component properties', error);
|
||||
}
|
||||
registerComponentProperties(node);
|
||||
}
|
||||
|
||||
if (!isSectionNode(node)) {
|
||||
|
|
|
@ -35,7 +35,7 @@ export const transformInstanceNode = async (
|
|||
nodeOverrides = transformOverrides(node);
|
||||
}
|
||||
|
||||
const fetchedOverrides = overrides.get(node.id) ?? [];
|
||||
const fetchedOverrides = [...(overrides.get(node.id) ?? [])];
|
||||
if (node.visible !== mainComponent.visible) {
|
||||
fetchedOverrides.push('visible');
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue