2024-06-06 05:17:17 -05:00
|
|
|
import {
|
|
|
|
transformConstraints,
|
|
|
|
transformFigmaIds,
|
2024-06-17 02:58:23 -05:00
|
|
|
transformOverrides,
|
2024-06-06 05:17:17 -05:00
|
|
|
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-19 01:10:20 -05:00
|
|
|
export const transformVectorNode = (node: VectorNode): GroupShape | PathShape => {
|
|
|
|
const children = transformVectorPaths(node);
|
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),
|
2024-06-17 02:58:23 -05:00
|
|
|
...transformConstraints(node),
|
|
|
|
...transformOverrides(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 {
|
2024-06-19 01:10:20 -05:00
|
|
|
...transformGroupNodeLike(node),
|
2024-05-30 10:54:37 -05:00
|
|
|
...transformFigmaIds(node),
|
2024-06-06 05:17:17 -05:00
|
|
|
...transformConstraints(node),
|
2024-06-17 02:58:23 -05:00
|
|
|
...transformOverrides(node),
|
2024-05-21 07:36:30 -05:00
|
|
|
children
|
2024-05-13 06:21:46 -05:00
|
|
|
};
|
|
|
|
};
|