( fills: ReadonlyArray<Paint> | undefined, )
| 4 | * Retrieve the first visible color that is being used by the layer, in case there are more than one. |
| 5 | */ |
| 6 | export const retrieveTopFill = ( |
| 7 | fills: ReadonlyArray<Paint> | undefined, |
| 8 | ): Paint | undefined => { |
| 9 | if (fills && Array.isArray(fills) && fills.length > 0) { |
| 10 | // on Figma, the top layer is always at the last position |
| 11 | // reverse, then try to find the first layer that is visible, if any. |
| 12 | return [...fills].reverse().find((d) => d.visible !== false); |
| 13 | } |
| 14 | |
| 15 | return undefined; |
| 16 | }; |
no outgoing calls
no test coverage detected