mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
dddc457281
* wip * wip * fix something? * wip * wip * wip * fixes * fixes * stroke image * wip * fixes * fixes * remove old code * fix translate fills * remove penpot public uri * remove old code * fix return undefineds * updated packages * finish refactor --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
30 lines
868 B
TypeScript
30 lines
868 B
TypeScript
import { translateStrokes } from '@plugin/translators';
|
|
|
|
import { ShapeAttributes } from '@ui/lib/types/shapes/shape';
|
|
|
|
const isVectorLike = (node: GeometryMixin | VectorLikeMixin): node is VectorLikeMixin => {
|
|
return 'vectorNetwork' in node;
|
|
};
|
|
|
|
const isIndividualStrokes = (
|
|
node: GeometryMixin | IndividualStrokesMixin
|
|
): node is IndividualStrokesMixin => {
|
|
return 'strokeTopWeight' in node;
|
|
};
|
|
|
|
const hasFillGeometry = (node: GeometryMixin): boolean => {
|
|
return node.fillGeometry.length > 0;
|
|
};
|
|
|
|
export const transformStrokes = async (
|
|
node: GeometryMixin | (GeometryMixin & IndividualStrokesMixin)
|
|
): Promise<Partial<ShapeAttributes>> => {
|
|
return {
|
|
strokes: await translateStrokes(
|
|
node,
|
|
hasFillGeometry(node),
|
|
isVectorLike(node) ? node.vectorNetwork : undefined,
|
|
isIndividualStrokes(node) ? node : undefined
|
|
)
|
|
};
|
|
};
|