ice.fo.utils
Version:
11 lines (8 loc) • 361 B
JavaScript
export default function getContrastColor(hexcolor) {
hexcolor = hexcolor.replace('#', '');
const r = parseInt(hexcolor.substr(0, 2), 16);
const g = parseInt(hexcolor.substr(2, 2), 16);
const b = parseInt(hexcolor.substr(4, 2), 16);
const yiq = Math.round(((r * 299) + (g * 587) + (b * 114)) / 1000);
return (yiq >= 125) ? '#000000' : '#FFFFFF';
}