0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-03 05:10:13 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/transformGroupNode.ts
Jordi Sala Morales 2557cbdacc
Implement flatten (#105)
* Implement flatten

* fix comment

* Add changelog
2024-05-13 13:21:46 +02:00

35 lines
920 B
TypeScript

import {
transformBlend,
transformDimensionAndPosition,
transformEffects,
transformSceneNode
} from '@plugin/transformers/partials';
import { transformChildren } from '@plugin/transformers/partials';
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
export const transformGroupNode = async (
node: GroupNode,
baseX: number,
baseY: number
): Promise<GroupShape> => {
return {
...transformGroupNodeLike(node, baseX, baseY),
...(await transformChildren(node, baseX, baseY))
};
};
export const transformGroupNodeLike = (
node: BaseNodeMixin & DimensionAndPositionMixin & BlendMixin & SceneNodeMixin & MinimalBlendMixin,
baseX: number,
baseY: number
): GroupShape => {
return {
type: 'group',
name: node.name,
...transformDimensionAndPosition(node, baseX, baseY),
...transformEffects(node),
...transformSceneNode(node),
...transformBlend(node)
};
};