Package Exports
- contrast
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (contrast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
contrast
Determine if the given color is light or dark.
This is useful for dynamically deciding which color a foreground color should be when placed over a given background color.
Install
npm install contrast --saveUsage
var contrast = require('contrast');
var el = document.querySelector('#some-element');
var bgColor = e.style.backgroundColor;
if (contrast(bgColor) === 'light') {
textColor = '#000';
}
else {
textColor = '#fff'
}
el.style.color = textColor;Run Tests
npm install
npm test