Repair mechanism for determining text color based on background color

pull/10616/head
Alex P 2018-04-09 15:07:26 -07:00
parent 31c5fa3fc7
commit dc3c272f19
1 changed files with 5 additions and 5 deletions

View File

@ -7,15 +7,15 @@ import {
THRESHOLD_TYPE_TEXT,
} from 'shared/constants/thresholds'
const luminanceThreshold = 0.5
const getLegibleTextColor = bgColorHex => {
const darkText = '#292933'
const lightText = '#ffffff'
return chroma(bgColorHex).luminance() < luminanceThreshold
? darkText
: lightText
const [red, green, blue] = chroma(bgColorHex).rgb()
const average = (red + green + blue) / 3
const mediumGrey = 128
return average > mediumGrey ? darkText : lightText
}
const findNearestCrossedThreshold = (colors, lastValue) => {