mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2025-01-03 05:10:13 -05:00
fix get component property definitions (#169)
This commit is contained in:
parent
14c9d02cc9
commit
5f884985b9
1 changed files with 20 additions and 16 deletions
|
@ -90,24 +90,28 @@ const getComponentTextPropertyOverrides = (
|
||||||
node: InstanceNode,
|
node: InstanceNode,
|
||||||
primaryComponent: ComponentNode | ComponentSetNode
|
primaryComponent: ComponentNode | ComponentSetNode
|
||||||
): ComponentTextPropertyOverride[] => {
|
): ComponentTextPropertyOverride[] => {
|
||||||
const componentPropertyDefinitions = Object.entries(
|
try {
|
||||||
primaryComponent.componentPropertyDefinitions
|
const componentPropertyDefinitions = Object.entries(
|
||||||
).filter(([, value]) => value.type === 'TEXT');
|
primaryComponent.componentPropertyDefinitions
|
||||||
|
).filter(([, value]) => value.type === 'TEXT');
|
||||||
|
|
||||||
const instanceComponentProperties = new Map(
|
const instanceComponentProperties = new Map(
|
||||||
Object.entries(node.componentProperties).filter(([, value]) => value.type === 'TEXT')
|
Object.entries(node.componentProperties).filter(([, value]) => value.type === 'TEXT')
|
||||||
);
|
);
|
||||||
|
|
||||||
return componentPropertyDefinitions
|
return componentPropertyDefinitions
|
||||||
.map(([key, value]) => {
|
.map(([key, value]) => {
|
||||||
const nodeValue = instanceComponentProperties.get(key);
|
const nodeValue = instanceComponentProperties.get(key);
|
||||||
return {
|
return {
|
||||||
id: key,
|
id: key,
|
||||||
...value,
|
...value,
|
||||||
value: nodeValue ? nodeValue.value : value.defaultValue
|
value: nodeValue ? nodeValue.value : value.defaultValue
|
||||||
} as ComponentTextPropertyOverride;
|
} as ComponentTextPropertyOverride;
|
||||||
})
|
})
|
||||||
.filter(({ value, defaultValue }) => value !== defaultValue);
|
.filter(({ value, defaultValue }) => value !== defaultValue);
|
||||||
|
} catch (error) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerTextVariableOverrides = (
|
const registerTextVariableOverrides = (
|
||||||
|
|
Loading…
Reference in a new issue