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
Alex Sánchez 36afc6da55
Boolean Groups (#115)
* wip

* wip

* fixes

* changeset

* fixes

* fixes

* fixes

* fixes

* minor fixes

* minor fixes
2024-05-27 10:05:23 +02:00

42 lines
1.2 KiB
TypeScript

import { PenpotNode } from '@ui/lib/types/penpotNode';
import {
transformBooleanNode,
transformEllipseNode,
transformFrameNode,
transformGroupNode,
transformPathNode,
transformRectangleNode,
transformTextNode,
transformVectorNode
} from '.';
export const transformSceneNode = async (
node: SceneNode,
baseX: number = 0,
baseY: number = 0
): Promise<PenpotNode | undefined> => {
switch (node.type) {
case 'RECTANGLE':
return await transformRectangleNode(node, baseX, baseY);
case 'ELLIPSE':
return await transformEllipseNode(node, baseX, baseY);
case 'SECTION':
case 'FRAME':
return await transformFrameNode(node, baseX, baseY);
case 'GROUP':
return await transformGroupNode(node, baseX, baseY);
case 'TEXT':
return await transformTextNode(node, baseX, baseY);
case 'VECTOR':
return await transformVectorNode(node, baseX, baseY);
case 'STAR':
case 'POLYGON':
case 'LINE':
return await transformPathNode(node, baseX, baseY);
case 'BOOLEAN_OPERATION':
return await transformBooleanNode(node, baseX, baseY);
}
console.error(`Unsupported node type: ${node.type}`);
};