2024-06-06 05:17:17 -05:00
|
|
|
import {
|
|
|
|
transformConstraints,
|
|
|
|
transformFigmaIds,
|
|
|
|
transformVectorPaths
|
|
|
|
} from '@plugin/transformers/partials';
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
import { GroupShape } from '@ui/lib/types/shapes/groupShape';
|
|
|
|
import { PathShape } from '@ui/lib/types/shapes/pathShape';
|
|
|
|
|
2024-05-21 07:36:30 -05:00
|
|
|
import { transformGroupNodeLike } from '.';
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Vector nodes can have multiple vector paths, each with its own fills.
|
|
|
|
*
|
2024-05-14 03:12:18 -05:00
|
|
|
* 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.
|
2024-05-13 06:21:46 -05:00
|
|
|
*/
|
2024-06-05 05:36:49 -05:00
|
|
|
export const transformVectorNode = (
|
2024-05-13 06:21:46 -05:00
|
|
|
node: VectorNode,
|
|
|
|
baseX: number,
|
|
|
|
baseY: number
|
2024-06-05 05:36:49 -05:00
|
|
|
): GroupShape | PathShape => {
|
|
|
|
const children = transformVectorPaths(node, baseX, baseY);
|
2024-05-21 07:36:30 -05:00
|
|
|
|
|
|
|
if (children.length === 1) {
|
|
|
|
return {
|
|
|
|
...children[0],
|
2024-05-30 10:54:37 -05:00
|
|
|
name: node.name,
|
2024-06-06 05:17:17 -05:00
|
|
|
...transformFigmaIds(node),
|
|
|
|
...transformConstraints(node)
|
2024-05-21 07:36:30 -05:00
|
|
|
};
|
2024-05-14 03:12:18 -05:00
|
|
|
}
|
2024-05-13 06:21:46 -05:00
|
|
|
|
|
|
|
return {
|
|
|
|
...transformGroupNodeLike(node, baseX, baseY),
|
2024-05-30 10:54:37 -05:00
|
|
|
...transformFigmaIds(node),
|
2024-06-06 05:17:17 -05:00
|
|
|
...transformConstraints(node),
|
2024-05-21 07:36:30 -05:00
|
|
|
children
|
2024-05-13 06:21:46 -05:00
|
|
|
};
|
|
|
|
};
|