Improved bg without fg

pull/201/head
M66B 4 years ago
parent df447bb94d
commit 96117bdba9

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

Loading…
Cancel
Save