mirror of
https://github.com/penpot/penpot-exporter-figma-plugin.git
synced 2024-12-23 06:04:01 -05:00
c114bd0b98
* strokes * adjust a few types * simplify --------- Co-authored-by: Jordi Sala Morales <jordism91@gmail.com>
30 lines
856 B
TypeScript
30 lines
856 B
TypeScript
import { translateStrokes } from '@plugin/translators';
|
|
|
|
import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes';
|
|
|
|
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 = (
|
|
node: GeometryMixin | (GeometryMixin & IndividualStrokesMixin)
|
|
): Partial<ShapeAttributes> => {
|
|
return {
|
|
strokes: translateStrokes(
|
|
node,
|
|
hasFillGeometry(node),
|
|
isVectorLike(node) ? node.vectorNetwork : undefined,
|
|
isIndividualStrokes(node) ? node : undefined
|
|
)
|
|
};
|
|
};
|