0
Fork 0
mirror of https://github.com/penpot/penpot-exporter-figma-plugin.git synced 2025-01-06 23:00:55 -05:00
penpot-exporter-figma-plugin/ui-src/parser/creators/symbols/symbolPathContent.ts
Jordi Sala Morales 738ebfeffe
Remove symbols when possible (#173)
* remove symbols for blend mode

* remove symbol for gradients

* optimize symbols for path contents

* optimize code

* remove symbols
2024-06-18 11:20:51 +02:00

30 lines
680 B
TypeScript

import {
Command,
PathContent,
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(segment => {
segment.command = symbolPathCommand(segment.command);
return 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;
}
};