mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
761093564b
* masked groups * changeset * refactor * refactor * refactor * fixes * fixes * wip * try to fix * refactor * refactor for better undestanding of code * refactor * fix name --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
22 lines
657 B
TypeScript
22 lines
657 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 = async (
|
|
node: ChildrenMixin,
|
|
baseX: number = 0,
|
|
baseY: number = 0
|
|
): Promise<Children> => {
|
|
const maskIndex = node.children.findIndex(nodeActsAsMask);
|
|
const containsMask = maskIndex !== -1;
|
|
|
|
return {
|
|
children: containsMask
|
|
? await translateMaskChildren(node.children, maskIndex, baseX, baseY)
|
|
: await translateChildren(node.children, baseX, baseY)
|
|
};
|
|
};
|