2024-05-29 10:33:29 -05:00
|
|
|
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
2024-05-29 05:52:21 -05:00
|
|
|
import {
|
|
|
|
transformBlend,
|
2024-05-29 10:33:29 -05:00
|
|
|
transformChildren,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformCornerRadius,
|
|
|
|
transformDimensionAndPosition,
|
|
|
|
transformEffects,
|
2024-05-30 10:54:37 -05:00
|
|
|
transformFigmaIds,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformFills,
|
|
|
|
transformProportion,
|
|
|
|
transformSceneNode,
|
|
|
|
transformStrokes
|
|
|
|
} from '@plugin/transformers/partials';
|
|
|
|
|
2024-05-29 10:33:29 -05:00
|
|
|
import { ComponentRoot } from '@ui/types';
|
2024-05-29 05:52:21 -05:00
|
|
|
|
|
|
|
export const transformComponentNode = async (
|
|
|
|
node: ComponentNode,
|
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
2024-05-29 10:33:29 -05:00
|
|
|
): Promise<ComponentRoot> => {
|
|
|
|
componentsLibrary.register(node.id, {
|
2024-05-29 05:52:21 -05:00
|
|
|
type: 'component',
|
|
|
|
name: node.name,
|
2024-05-31 06:32:59 -05:00
|
|
|
path: node.parent?.type === 'COMPONENT_SET' ? node.parent.name : '',
|
2024-05-30 10:54:37 -05:00
|
|
|
...transformFigmaIds(node),
|
2024-05-29 05:52:21 -05:00
|
|
|
...(await transformFills(node)),
|
|
|
|
...transformEffects(node),
|
|
|
|
...(await transformStrokes(node)),
|
|
|
|
...transformSceneNode(node),
|
|
|
|
...transformBlend(node),
|
|
|
|
...transformProportion(node),
|
|
|
|
...transformCornerRadius(node),
|
|
|
|
...(await transformChildren(node, baseX + node.x, baseY + node.y)),
|
|
|
|
...transformDimensionAndPosition(node, baseX, baseY)
|
2024-05-29 10:33:29 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
figmaId: node.id,
|
|
|
|
type: 'component'
|
2024-05-29 05:52:21 -05:00
|
|
|
};
|
|
|
|
};
|