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
Jordi Sala Morales e5f2943532
Implement rotation for frames and sections (#163)
* Implement rotation for frames and sections

* wip

* finish implementation

* add changelog
2024-06-14 16:28:01 +02:00

50 lines
1.4 KiB
TypeScript

import { componentsLibrary } from '@plugin/ComponentLibrary';
import {
transformAutoLayout,
transformBlend,
transformChildren,
transformConstraints,
transformCornerRadius,
transformDimension,
transformEffects,
transformFigmaIds,
transformFills,
transformLayoutAttributes,
transformProportion,
transformRotationAndPosition,
transformSceneNode,
transformStrokes
} from '@plugin/transformers/partials';
import { ComponentRoot } from '@ui/types';
export const transformComponentNode = async (
node: ComponentNode,
baseRotation: number
): Promise<ComponentRoot> => {
componentsLibrary.register(node.id, {
type: 'component',
name: node.name,
path: node.parent?.type === 'COMPONENT_SET' ? node.parent.name : '',
showContent: !node.clipsContent,
...transformFigmaIds(node),
...transformFills(node),
...transformEffects(node),
...transformStrokes(node),
...transformSceneNode(node),
...transformBlend(node),
...transformProportion(node),
...transformLayoutAttributes(node),
...transformCornerRadius(node),
...(await transformChildren(node, node.rotation + baseRotation)),
...transformDimension(node),
...transformRotationAndPosition(node, baseRotation),
...transformConstraints(node),
...transformAutoLayout(node)
});
return {
figmaId: node.id,
type: 'component'
};
};