0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2024-12-22 13:43:03 -05:00

decide to transform to path or group based on regions (#110)

This commit is contained in:
Jordi Sala Morales 2024-05-14 10:12:18 +02:00 committed by GitHub
parent 3118d36f0a
commit a734c8a6ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,15 +8,17 @@ import { transformGroupNodeLike, transformPathNode } from '.';
/* /*
* Vector nodes can have multiple vector paths, each with its own fills. * 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 there are no regions on the vector network, 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 regions, we treat the vector node as a `GroupShape` with multiple `PathShape` children.
*/ */
export const transformVectorNode = async ( export const transformVectorNode = async (
node: VectorNode, node: VectorNode,
baseX: number, baseX: number,
baseY: number baseY: number
): Promise<GroupShape | PathShape> => { ): 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 { return {
...transformGroupNodeLike(node, baseX, baseY), ...transformGroupNodeLike(node, baseX, baseY),