Skip to content

Commit

Permalink
improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Cenadros committed May 30, 2024
1 parent cbed267 commit 1cb81f8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion plugin-src/transformers/transformInstanceNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const transformInstanceNode = async (
return {
type: 'instance',
mainComponentFigmaId: mainComponent.id,
isComponentRoot: node.parent === null || node.parent.type !== 'COMPONENT', // @TODO: check multiple hierarchy
isComponentRoot: isComponentRoot(node),
...transformFigmaIds(node),
...(await transformFills(node)),
...transformEffects(node),
Expand All @@ -42,3 +42,14 @@ export const transformInstanceNode = async (
...(await transformChildren(node, baseX + node.x, baseY + node.y))
};
};

const isComponentRoot = (node: InstanceNode): boolean => {
let parent = node.parent;
while (parent !== null) {
if (parent.type === 'COMPONENT' || parent.type === 'INSTANCE') {
return false;
}
parent = parent.parent;
}
return true;
};

0 comments on commit 1cb81f8

Please sign in to comment.