Improved bg without fg

This commit is contained in:
M66B 2021-08-04 09:42:41 +02:00
parent df447bb94d
commit 96117bdba9
1 changed files with 7 additions and 4 deletions

View File

@ -637,7 +637,7 @@ public class HtmlHelper {
if (color != null)
element.attr("x-background", encodeWebColor(color));
if (dark) {
if (color != null && dark) {
boolean fg = false;
if (text_color) {
fg = (parseColor(kv.get("color")) != null);
@ -650,12 +650,15 @@ public class HtmlHelper {
}
// Dark theme, background color with no text color:
// force text color
if (!fg)
// force (inverse) text color
if (!fg) {
double lum = (color == Color.TRANSPARENT ? 0 : ColorUtils.calculateLuminance(color));
int c = (lum < 0.5 ? textColorPrimary : textColorPrimaryInverse);
sb.append("color")
.append(':')
.append(encodeWebColor(textColorPrimaryInverse))
.append(encodeWebColor(c))
.append(";");
}
}
}