MCPcopy Create free account
hub / github.com/bernaferrari/FigmaToCode / commonStroke

Function commonStroke

packages/backend/src/common/commonStroke.ts:3–31  ·  view source on GitHub ↗
(
  node: SceneNode,
  divideBy: number = 1,
)

Source from the content-addressed store, hash-verified

1import { BorderSide } from "types";
2
3export const commonStroke = (
4 node: SceneNode,
5 divideBy: number = 1,
6): BorderSide | null => {
7 if (!("strokes" in node) || !node.strokes || node.strokes.length === 0) {
8 return null;
9 }
10
11 if ("strokeTopWeight" in node) {
12 if (
13 node.strokeTopWeight === node.strokeBottomWeight &&
14 node.strokeTopWeight === node.strokeLeftWeight &&
15 node.strokeTopWeight === node.strokeRightWeight
16 ) {
17 return { all: node.strokeTopWeight / divideBy };
18 }
19
20 return {
21 left: node.strokeLeftWeight / divideBy,
22 top: node.strokeTopWeight / divideBy,
23 right: node.strokeRightWeight / divideBy,
24 bottom: node.strokeBottomWeight / divideBy,
25 };
26 } else if (node.strokeWeight !== figma.mixed && node.strokeWeight !== 0) {
27 return { all: node.strokeWeight / divideBy };
28 }
29
30 return null;
31};

Callers 6

getSingleStrokeWidthFunction · 0.90
flutterBorderFunction · 0.90
tailwindBorderWidthFunction · 0.90
borderMethod · 0.90
swiftUIStrokeFunction · 0.90
composeBorderFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected