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 a079f168df
Analytics (#228)
* metricts-sentry

* fixes

* refactor

* mixpanel integration

* improvements

* improvements

* fixes

* changeset

* fixes

* fixes

* Update .changeset/few-scissors-sleep.md

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* Update manifest.json

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* Update vite.config.ts

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>

* fixes

* fixes

* fixes

* lint

---------

Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
2024-10-28 11:22:50 +01:00

69 lines
1.6 KiB
TypeScript

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':
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;
};