mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
cc5553ce7c
* Wip * refactor strokes * fix * fix * fix * refactor * more refactor * add changeset and fix issue fix line node * refactor * continue the refactor * refactor fills * fix * wip * try another approach * refactor * refactor * more refactor * refactor * wip * wip * minor improvements * minor fixes * refactor --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
32 lines
902 B
TypeScript
32 lines
902 B
TypeScript
import { transformVectorPaths } from '@plugin/transformers/partials';
|
|
|
|
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
|
|
import { PathShape } from '@ui/lib/types/shapes/pathShape';
|
|
|
|
import { transformGroupNodeLike } from '.';
|
|
|
|
/*
|
|
* Vector nodes can have multiple vector paths, each with its own fills.
|
|
*
|
|
* 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> => {
|
|
const children = await transformVectorPaths(node, baseX, baseY);
|
|
|
|
if (children.length === 1) {
|
|
return {
|
|
...children[0],
|
|
name: node.name
|
|
};
|
|
}
|
|
|
|
return {
|
|
...transformGroupNodeLike(node, baseX, baseY),
|
|
children
|
|
};
|
|
};
|