Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let background = getComputedBackgroundColor(el)
const [ aa_contrast, aaa_contrast ] = [
isReadable(background, foreground, { level: "AA", size: textSize.toLowerCase() }),
isReadable(background, foreground, { level: "AAA", size: textSize.toLowerCase() })
]
return foreground === background
? `🤷♂️ foreground matches background`
: `
<span>Color contrast</span>
<span value="">
<span style="background-color:${background};
color:${foreground};">${Math.floor(readability(background, foreground) * 100) / 100}</span>
</span>
<span>› AA ${textSize}</span>
<span style="${aa_contrast ? 'color:green;' : 'color:red'}" value="">${aa_contrast ? '✓' : '×'}</span>
<span>› AAA ${textSize}</span>
<span style="${aaa_contrast ? 'color:green;' : 'color:red'}" value="">${aaa_contrast ? '✓' : '×'}</span>
`
}