(node: SceneNode)
| 1 | import { CornerRadius } from "types"; |
| 2 | |
| 3 | export const getCommonRadius = (node: SceneNode): CornerRadius => { |
| 4 | if ("rectangleCornerRadii" in node) { |
| 5 | const [topLeft, topRight, bottomRight, bottomLeft] = |
| 6 | node.rectangleCornerRadii as any; |
| 7 | if ( |
| 8 | topLeft === topRight && |
| 9 | topLeft === bottomRight && |
| 10 | topLeft === bottomLeft |
| 11 | ) { |
| 12 | return { all: topLeft }; |
| 13 | } |
| 14 | |
| 15 | return { |
| 16 | topLeft, |
| 17 | topRight, |
| 18 | bottomRight, |
| 19 | bottomLeft, |
| 20 | }; |
| 21 | } |
| 22 | |
| 23 | if ( |
| 24 | "cornerRadius" in node && |
| 25 | node.cornerRadius !== figma.mixed && |
| 26 | node.cornerRadius |
| 27 | ) { |
| 28 | return { all: node.cornerRadius }; |
| 29 | } |
| 30 | |
| 31 | if ("topLeftRadius" in node) { |
| 32 | if ( |
| 33 | node.topLeftRadius === node.topRightRadius && |
| 34 | node.topLeftRadius === node.bottomRightRadius && |
| 35 | node.topLeftRadius === node.bottomLeftRadius |
| 36 | ) { |
| 37 | return { all: node.topLeftRadius }; |
| 38 | } |
| 39 | |
| 40 | return { |
| 41 | topLeft: node.topLeftRadius, |
| 42 | topRight: node.topRightRadius, |
| 43 | bottomRight: node.bottomRightRadius, |
| 44 | bottomLeft: node.bottomLeftRadius, |
| 45 | }; |
| 46 | } |
| 47 | |
| 48 | return { all: 0 }; |
| 49 | }; |
no outgoing calls
no test coverage detected