commit: a00792a7750256ff5b95c0692d3ffce81219962f
parent 3548075abb41baffb05ebd8f45886bb487ed3961
Author: Henry Jameson <me@hjkos.com>
Date: Tue, 31 Dec 2024 13:30:23 +0200
limit how dark/light can auto-contrast can get
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/services/color_convert/color_convert.js b/src/services/color_convert/color_convert.js
@@ -210,7 +210,7 @@ export const getTextColor = function (bg, text, preserve) {
const result = convert(rgb2hex(workColor)).hsl
const delta = result.l > 50 ? 1 : -1
const multiplier = 10
- while (contrast < 4.5 && result.l > 0 && result.l < 100) {
+ while (contrast < 4.5 && result.l > 20 && result.l < 80) {
result.l += delta * multiplier
contrast = getContrastRatio(bg, convert(result).rgb)
console.log(convert(result).hex, result.l, contrast)