0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 21:53:27 -05:00
penpot-exporter-figma-plugin/plugin-src/transformers/partials/transformChildren.ts
2024-06-19 07:05:10 +00:00

18 lines
556 B
TypeScript

import { translateChildren, translateMaskChildren } from '@plugin/translators';
import { Children } from '@ui/lib/types/utils/children';
const nodeActsAsMask = (node: SceneNode): boolean => {
return 'isMask' in node && node.isMask;
};
export const transformChildren = (node: ChildrenMixin): Children => {
const maskIndex = node.children.findIndex(nodeActsAsMask);
const containsMask = maskIndex !== -1;
return {
children: containsMask
? translateMaskChildren(node.children, maskIndex)
: translateChildren(node.children)
};
};