Skip to content

Commit

Permalink
decide to transform to path or group based on regions (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
jordisala1991 authored May 14, 2024
1 parent 3118d36 commit a734c8a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions plugin-src/transformers/transformVectorNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ import { transformGroupNodeLike, transformPathNode } from '.';
/*
* Vector nodes can have multiple vector paths, each with its own fills.
*
* If the fills are not mixed, we treat it like a normal `PathShape`.
* If the fills are mixed, we treat the vector node as a `GroupShape` with multiple `PathShape` children.
* If there are no regions on the vector network, we treat it like a normal `PathShape`.
* If there are regions, we treat the vector node as a `GroupShape` with multiple `PathShape` children.
*/
export const transformVectorNode = async (
node: VectorNode,
baseX: number,
baseY: number
): Promise<GroupShape | PathShape> => {
if (node.fills !== figma.mixed) return transformPathNode(node, baseX, baseY);
if ((node.vectorNetwork.regions ?? []).length === 0) {
return transformPathNode(node, baseX, baseY);
}

return {
...transformGroupNodeLike(node, baseX, baseY),
Expand Down

0 comments on commit a734c8a

Please sign in to comment.