From 36198d500c911845a5142413be10e04f113a01ee Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 7 Aug 2020 10:50:00 +0530 Subject: [PATCH] Content server: Fix incorrect text color in detailed book list in dark mode --- src/pyj/book_list/details_list.pyj | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pyj/book_list/details_list.pyj b/src/pyj/book_list/details_list.pyj index 08ba0886ee..df5527fa35 100644 --- a/src/pyj/book_list/details_list.pyj +++ b/src/pyj/book_list/details_list.pyj @@ -5,7 +5,7 @@ from __python__ import bound_methods, hash_literals from elementmaker import E from gettext import gettext as _ -from book_list.theme import get_color +from book_list.theme import css_for_variables, get_color from dom import build_rule, clear, set_css, svgicon from session import get_interface_data from utils import fmt_sidx, safe_set_inner_html, sandboxed_html @@ -66,8 +66,11 @@ def on_img_load(img, load_type): def sandbox_css(): - if not sandbox_css.ans: - sandbox_css.ans = 'html {{ overflow: hidden; color: {} }}'.format(get_color('window-foreground')) + is_dark_theme = window.matchMedia('(prefers-color-scheme: dark)').matches + if not sandbox_css.ans or sandbox_css.is_dark_theme is not is_dark_theme: + sandbox_css.ans = css_for_variables() + '\n\n' + sandbox_css.ans += 'html {{ overflow: hidden; color: {} }}'.format(get_color('window-foreground')) + sandbox_css.is_dark_theme = is_dark_theme return sandbox_css.ans