Created
February 5, 2018 01:58
-
-
Save t-laird/8f9918324c7063ed62c6a0a48beec57c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//from GitPoint's color helper https://github.com/gitpoint/git-point/blob/master/src/utils/color-helpers.js | |
export const getFontColorByBackground = bgColor => { | |
const r = parseInt(bgColor.substr(0, 2), 16); | |
const g = parseInt(bgColor.substr(2, 2), 16); | |
const b = parseInt(bgColor.substr(4, 2), 16); | |
const yiq = (r * 299 + g * 587 + b * 114) / 1000; | |
return yiq >= 128 ? colors.black : colors.white; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment