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/transformComponentNode.ts
Alex Sánchez 5d4ace337b
Components Library (#125)
* components library management

* components library management

* fixes

* fixes
2024-05-29 17:33:29 +02:00

40 lines
1 KiB
TypeScript

import { componentsLibrary } from '@plugin/ComponentLibrary';
import {
transformBlend,
transformChildren,
transformCornerRadius,
transformDimensionAndPosition,
transformEffects,
transformFills,
transformProportion,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
import { ComponentRoot } from '@ui/types';
export const transformComponentNode = async (
node: ComponentNode,
baseX: number,
baseY: number
): Promise<ComponentRoot> => {
componentsLibrary.register(node.id, {
type: 'component',
name: node.name,
path: '',
...(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)
});
return {
figmaId: node.id,
type: 'component'
};
};