mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-22 13:43:03 -05:00
202e7f4fda
* Apply rotations to any figure * add changelog * apply rotations to curves too
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import {
|
|
transformConstraints,
|
|
transformFigmaIds,
|
|
transformOverrides,
|
|
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 = (
|
|
node: VectorNode,
|
|
baseRotation: number
|
|
): GroupShape | PathShape => {
|
|
const children = transformVectorPaths(node, baseRotation);
|
|
|
|
if (children.length === 1) {
|
|
return {
|
|
...children[0],
|
|
name: node.name,
|
|
...transformFigmaIds(node),
|
|
...transformConstraints(node),
|
|
...transformOverrides(node)
|
|
};
|
|
}
|
|
|
|
return {
|
|
...transformGroupNodeLike(node, baseRotation),
|
|
...transformFigmaIds(node),
|
|
...transformConstraints(node),
|
|
...transformOverrides(node),
|
|
children
|
|
};
|
|
};
|