2024-05-29 10:33:29 -05:00
|
|
|
import { componentsLibrary } from '@plugin/ComponentLibrary';
|
2024-05-29 05:52:21 -05:00
|
|
|
import {
|
2024-06-14 03:18:34 -05:00
|
|
|
transformAutoLayout,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformBlend,
|
2024-05-29 10:33:29 -05:00
|
|
|
transformChildren,
|
2024-06-06 05:17:17 -05:00
|
|
|
transformConstraints,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformCornerRadius,
|
2024-06-14 09:28:01 -05:00
|
|
|
transformDimension,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformEffects,
|
2024-05-30 10:54:37 -05:00
|
|
|
transformFigmaIds,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformFills,
|
2024-06-14 03:18:34 -05:00
|
|
|
transformLayoutAttributes,
|
2024-05-29 05:52:21 -05:00
|
|
|
transformProportion,
|
2024-06-14 09:28:01 -05:00
|
|
|
transformRotationAndPosition,
|
2024-05-29 05:52:21 -05:00
|
|
|
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
|
|
|
|
2024-06-19 01:10:20 -05:00
|
|
|
export const transformComponentNode = async (node: ComponentNode): Promise<ComponentRoot> => {
|
2024-05-29 10:33:29 -05:00
|
|
|
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-06-06 02:37:35 -05:00
|
|
|
showContent: !node.clipsContent,
|
2024-05-30 10:54:37 -05:00
|
|
|
...transformFigmaIds(node),
|
2024-06-05 05:36:49 -05:00
|
|
|
...transformFills(node),
|
2024-05-29 05:52:21 -05:00
|
|
|
...transformEffects(node),
|
2024-06-05 05:36:49 -05:00
|
|
|
...transformStrokes(node),
|
2024-05-29 05:52:21 -05:00
|
|
|
...transformSceneNode(node),
|
|
|
|
...transformBlend(node),
|
|
|
|
...transformProportion(node),
|
2024-06-18 06:10:30 -05:00
|
|
|
...transformLayoutAttributes(node, true),
|
2024-05-29 05:52:21 -05:00
|
|
|
...transformCornerRadius(node),
|
2024-06-19 01:10:20 -05:00
|
|
|
...(await transformChildren(node)),
|
2024-06-14 09:28:01 -05:00
|
|
|
...transformDimension(node),
|
2024-06-19 01:10:20 -05:00
|
|
|
...transformRotationAndPosition(node),
|
2024-06-14 03:18:34 -05:00
|
|
|
...transformConstraints(node),
|
|
|
|
...transformAutoLayout(node)
|
2024-05-29 10:33:29 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
figmaId: node.id,
|
2024-06-18 02:50:38 -05:00
|
|
|
type: 'component',
|
|
|
|
name: node.name
|
2024-05-29 05:52:21 -05:00
|
|
|
};
|
|
|
|
};
|