( node: SceneNode, divideBy: number = 1, )
| 1 | import { BorderSide } from "types"; |
| 2 | |
| 3 | export 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 | }; |
no outgoing calls
no test coverage detected