0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformSceneNode.ts

70 lines
1.6 KiB
TypeScript
Raw Normal View History

import { PenpotNode } from '@ui/types';
import {
transformBooleanNode,
transformComponentNode,
transformEllipseNode,
transformFrameNode,
transformGroupNode,
transformInstanceNode,
transformLineNode,
transformPathNode,
transformRectangleNode,
transformTextNode,
transformVectorNode
} from '.';
export const transformSceneNode = async (node: SceneNode): Promise<PenpotNode | undefined> => {
let penpotNode: PenpotNode | undefined;
figma.ui.postMessage({
type: 'PROGRESS_CURRENT_ITEM',
data: node.name
});
switch (node.type) {
case 'RECTANGLE':
penpotNode = transformRectangleNode(node);
break;
case 'ELLIPSE':
penpotNode = transformEllipseNode(node);
break;
case 'SECTION':
case 'FRAME':
2024-05-31 06:32:59 -05:00
case 'COMPONENT_SET':
penpotNode = await transformFrameNode(node);
break;
case 'GROUP':
penpotNode = await transformGroupNode(node);
break;
case 'TEXT':
penpotNode = transformTextNode(node);
break;
case 'VECTOR':
penpotNode = transformVectorNode(node);
break;
case 'LINE':
penpotNode = transformLineNode(node);
break;
case 'STAR':
case 'POLYGON':
penpotNode = transformPathNode(node);
break;
case 'BOOLEAN_OPERATION':
penpotNode = await transformBooleanNode(node);
break;
case 'COMPONENT':
penpotNode = await transformComponentNode(node);
break;
case 'INSTANCE':
penpotNode = await transformInstanceNode(node);
break;
}
if (penpotNode === undefined) {
console.warn(`Unsupported node type: ${node.type}`);
}
return penpotNode;
};