From b062110c3d57cd3f8269e0776bcbb1fa7cb7a3f4 Mon Sep 17 00:00:00 2001 From: Jordi Sala Morales Date: Thu, 18 Apr 2024 07:27:21 +0000 Subject: [PATCH] simplify --- .../transformers/partials/transformStrokes.ts | 29 ++----------------- plugin-src/translators/translateStrokes.ts | 3 +- 2 files changed, 3 insertions(+), 29 deletions(-) diff --git a/plugin-src/transformers/partials/transformStrokes.ts b/plugin-src/transformers/partials/transformStrokes.ts index 4aaeb759..05cc5e05 100644 --- a/plugin-src/transformers/partials/transformStrokes.ts +++ b/plugin-src/transformers/partials/transformStrokes.ts @@ -2,13 +2,6 @@ import { translateStrokes } from '@plugin/translators'; import { ShapeAttributes } from '@ui/lib/types/shape/shapeAttributes'; -export type NodeStrokes = { - strokes: readonly Paint[]; - strokeWeight: number | typeof figma.mixed; - strokeAlign: 'CENTER' | 'INSIDE' | 'OUTSIDE'; - dashPattern: readonly number[]; -}; - const isVectorLike = (node: GeometryMixin | VectorLikeMixin): node is VectorLikeMixin => { return 'vectorNetwork' in node; }; @@ -23,33 +16,15 @@ const hasFillGeometry = (node: GeometryMixin): boolean => { return node.fillGeometry.length > 0; }; -const getNodeStrokes = (node: GeometryMixin): NodeStrokes => { - return { - strokes: node.strokes, - strokeWeight: node.strokeWeight, - strokeAlign: node.strokeAlign, - dashPattern: node.dashPattern - }; -}; - -const getIndividualStrokes = (node: IndividualStrokesMixin): IndividualStrokesMixin => { - return { - strokeTopWeight: node.strokeTopWeight, - strokeRightWeight: node.strokeRightWeight, - strokeBottomWeight: node.strokeBottomWeight, - strokeLeftWeight: node.strokeLeftWeight - }; -}; - export const transformStrokes = ( node: GeometryMixin | (GeometryMixin & IndividualStrokesMixin) ): Partial => { return { strokes: translateStrokes( - getNodeStrokes(node), + node, hasFillGeometry(node), isVectorLike(node) ? node.vectorNetwork : undefined, - isIndividualStrokes(node) ? getIndividualStrokes(node) : undefined + isIndividualStrokes(node) ? node : undefined ) }; }; diff --git a/plugin-src/translators/translateStrokes.ts b/plugin-src/translators/translateStrokes.ts index 1ad60dcd..e380213d 100644 --- a/plugin-src/translators/translateStrokes.ts +++ b/plugin-src/translators/translateStrokes.ts @@ -1,10 +1,9 @@ -import { NodeStrokes } from '@plugin/transformers/partials'; import { translateFill } from '@plugin/translators/translateFills'; import { Stroke, StrokeAlignment, StrokeCaps } from '@ui/lib/types/utils/stroke'; export const translateStrokes = ( - nodeStrokes: NodeStrokes, + nodeStrokes: MinimalStrokesMixin, hasFillGeometry?: boolean, vectorNetwork?: VectorNetwork, individualStrokes?: IndividualStrokesMixin