0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-05 06:10:52 -05:00
penpot-exporter-figma-plugin/ui-src/parser/creators/symbols/symbolPathContent.ts

34 lines
757 B
TypeScript

import {
Command,
PathContent,
Segment,
VECTOR_CLOSE_PATH,
VECTOR_CURVE_TO,
VECTOR_LINE_TO,
VECTOR_MOVE_TO
} from '@ui/lib/types/shapes/pathShape';
export const symbolPathContent = (content: PathContent): PathContent =>
content.map(({ command: stringCommand, ...rest }) => {
const command = symbolPathCommand(stringCommand);
return {
command,
...rest
} as Segment;
});
const symbolPathCommand = (command: Command): Command => {
if (typeof command !== 'string') return command;
switch (command) {
case 'line-to':
return VECTOR_LINE_TO;
case 'close-path':
return VECTOR_CLOSE_PATH;
case 'move-to':
return VECTOR_MOVE_TO;
case 'curve-to':
return VECTOR_CURVE_TO;
}
};