2024-05-29 10:33:29 -05:00
|
|
|
import { PenpotNode } from '@ui/types';
|
2024-04-12 09:52:36 -05:00
|
|
|
|
2024-04-12 06:55:42 -05:00
|
|
|
import {
|
2024-05-27 03:05:23 -05:00
|
|
|
transformBooleanNode,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformComponentNode,
|
2024-04-12 06:55:42 -05:00
|
|
|
transformEllipseNode,
|
|
|
|
transformFrameNode,
|
|
|
|
transformGroupNode,
|
2024-05-30 10:54:37 -05:00
|
|
|
transformInstanceNode,
|
2024-06-14 03:33:23 -05:00
|
|
|
transformLineNode,
|
2024-04-17 03:53:38 -05:00
|
|
|
transformPathNode,
|
2024-04-12 06:55:42 -05:00
|
|
|
transformRectangleNode,
|
2024-05-13 06:21:46 -05:00
|
|
|
transformTextNode,
|
|
|
|
transformVectorNode
|
2024-04-12 06:55:42 -05:00
|
|
|
} from '.';
|
|
|
|
|
2024-06-19 01:10:20 -05:00
|
|
|
export const transformSceneNode = async (node: SceneNode): Promise<PenpotNode | undefined> => {
|
2024-05-31 04:25:32 -05:00
|
|
|
let penpotNode: PenpotNode | undefined;
|
|
|
|
|
|
|
|
figma.ui.postMessage({
|
2024-06-06 10:24:59 -05:00
|
|
|
type: 'PROGRESS_CURRENT_ITEM',
|
2024-05-31 04:25:32 -05:00
|
|
|
data: node.name
|
|
|
|
});
|
|
|
|
|
2024-04-12 06:55:42 -05:00
|
|
|
switch (node.type) {
|
|
|
|
case 'RECTANGLE':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformRectangleNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'ELLIPSE':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformEllipseNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-04-17 04:38:13 -05:00
|
|
|
case 'SECTION':
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'FRAME':
|
2024-05-31 06:32:59 -05:00
|
|
|
case 'COMPONENT_SET':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = await transformFrameNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'GROUP':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = await transformGroupNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-04-12 06:55:42 -05:00
|
|
|
case 'TEXT':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformTextNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-05-13 06:21:46 -05:00
|
|
|
case 'VECTOR':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformVectorNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-06-14 03:33:23 -05:00
|
|
|
case 'LINE':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformLineNode(node);
|
2024-06-14 03:33:23 -05:00
|
|
|
break;
|
2024-04-16 09:08:39 -05:00
|
|
|
case 'STAR':
|
|
|
|
case 'POLYGON':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = transformPathNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-05-27 03:05:23 -05:00
|
|
|
case 'BOOLEAN_OPERATION':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = await transformBooleanNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-05-29 05:52:21 -05:00
|
|
|
case 'COMPONENT':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = await transformComponentNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
2024-05-30 10:54:37 -05:00
|
|
|
case 'INSTANCE':
|
2024-06-19 01:10:20 -05:00
|
|
|
penpotNode = await transformInstanceNode(node);
|
2024-05-31 04:25:32 -05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (penpotNode === undefined) {
|
2024-10-28 05:22:50 -05:00
|
|
|
console.warn(`Unsupported node type: ${node.type}`);
|
2024-04-12 06:55:42 -05:00
|
|
|
}
|
|
|
|
|
2024-05-31 04:25:32 -05:00
|
|
|
return penpotNode;
|
2024-04-12 06:55:42 -05:00
|
|
|
};
|