2024-05-29 05:52:21 -05:00
|
|
|
import { PenpotFile } from '@ui/lib/types/penpotFile';
|
2024-05-29 10:33:29 -05:00
|
|
|
import { PenpotNode } from '@ui/types';
|
2024-05-29 05:52:21 -05:00
|
|
|
|
|
|
|
import {
|
|
|
|
createArtboard,
|
|
|
|
createBool,
|
|
|
|
createCircle,
|
|
|
|
createComponent,
|
2024-05-30 10:54:37 -05:00
|
|
|
createComponentInstance,
|
2024-05-29 05:52:21 -05:00
|
|
|
createGroup,
|
|
|
|
createPath,
|
|
|
|
createRectangle,
|
|
|
|
createText
|
|
|
|
} from '.';
|
|
|
|
|
|
|
|
export const createItems = (file: PenpotFile, nodes: PenpotNode[]) => {
|
|
|
|
for (const node of nodes) {
|
|
|
|
createItem(file, node);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const createItem = (file: PenpotFile, node: PenpotNode) => {
|
|
|
|
switch (node.type) {
|
|
|
|
case 'rect':
|
|
|
|
return createRectangle(file, node);
|
|
|
|
case 'circle':
|
|
|
|
return createCircle(file, node);
|
|
|
|
case 'frame':
|
|
|
|
return createArtboard(file, node);
|
|
|
|
case 'group':
|
|
|
|
return createGroup(file, node);
|
|
|
|
case 'path':
|
|
|
|
return createPath(file, node);
|
|
|
|
case 'text':
|
|
|
|
return createText(file, node);
|
|
|
|
case 'bool':
|
|
|
|
return createBool(file, node);
|
|
|
|
case 'component':
|
|
|
|
return createComponent(file, node);
|
2024-05-30 10:54:37 -05:00
|
|
|
case 'instance':
|
|
|
|
return createComponentInstance(file, node);
|
2024-05-29 05:52:21 -05:00
|
|
|
}
|
|
|
|
};
|