Skip to content

Instantly share code, notes, and snippets.

@danhollick
Created February 2, 2020 13:13
Show Gist options
  • Select an option

  • Save danhollick/5b3fcf1aba11b7db7a643bf8aa6a67e0 to your computer and use it in GitHub Desktop.

Select an option

Save danhollick/5b3fcf1aba11b7db7a643bf8aa6a67e0 to your computer and use it in GitHub Desktop.
Send selection info to iFrame
figma.on('selectionchange', () => {
if (figma.currentPage.selection.length > 1) {
const selection = figma.currentPage.selection.filter(
node => node.fills.length > 0 && node.fills[0].type === 'SOLID'
)
const fills = selection.map(node => node.fills[0])
const contrast = calculateContrast(fills[0].color, fills[1].color)
sendContrastInfo(contrast, fills[0].color, fills[1].color)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment