mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix rendering of comments in metadata display when using a dark color scheme. Fixes #1995214 [Metadata comments in E-book viewer have white background in any dark color scheme](https://bugs.launchpad.net/calibre/+bug/1995214)
This commit is contained in:
parent
f0ba30d7d3
commit
608b328f25
@ -16,7 +16,7 @@ from book_list.library_data import (
|
|||||||
)
|
)
|
||||||
from book_list.router import back, home, open_book, report_a_load_failure
|
from book_list.router import back, home, open_book, report_a_load_failure
|
||||||
from book_list.theme import (
|
from book_list.theme import (
|
||||||
browser_in_dark_mode, get_color, get_color_as_rgba, get_font_size
|
color_scheme, get_color, get_color_as_rgba, get_font_size
|
||||||
)
|
)
|
||||||
from book_list.top_bar import add_button, clear_buttons, create_top_bar, set_title
|
from book_list.top_bar import add_button, clear_buttons, create_top_bar, set_title
|
||||||
from book_list.ui import query_as_href, set_panel_handler, show_panel
|
from book_list.ui import query_as_href, set_panel_handler, show_panel
|
||||||
@ -155,8 +155,7 @@ if window?:
|
|||||||
|
|
||||||
def adjusting_sandboxed_html(html, extra_css):
|
def adjusting_sandboxed_html(html, extra_css):
|
||||||
color = get_color_as_rgba('window-foreground')
|
color = get_color_as_rgba('window-foreground')
|
||||||
cs = 'dark' if browser_in_dark_mode() else 'light'
|
css = f'\n\n:root {{ color-scheme: {color_scheme()} }}\n\nhtml, body {{ overflow: hidden; color: rgba({color[0]}, {color[1]}, {color[2]}, {color[3]}) }}'
|
||||||
css = f'\n\n:root {{ color-scheme: {cs} }}\n\nhtml, body {{ overflow: hidden; color: rgba({color[0]}, {color[1]}, {color[2]}, {color[3]}) }}'
|
|
||||||
if extra_css:
|
if extra_css:
|
||||||
css += '\n\n' + extra_css
|
css += '\n\n' + extra_css
|
||||||
# allow-same-origin is needed for resizing and allow-popups is needed for
|
# allow-same-origin is needed for resizing and allow-popups is needed for
|
||||||
|
@ -4,7 +4,7 @@ from __python__ import bound_methods, hash_literals
|
|||||||
|
|
||||||
from elementmaker import E
|
from elementmaker import E
|
||||||
|
|
||||||
from book_list.theme import browser_in_dark_mode, get_color, get_color_as_rgba
|
from book_list.theme import color_scheme, get_color, get_color_as_rgba
|
||||||
from dom import add_extra_css, build_rule, clear, svgicon
|
from dom import add_extra_css, build_rule, clear, svgicon
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _
|
||||||
from iframe_comm import IframeClient, create_wrapped_iframe
|
from iframe_comm import IframeClient, create_wrapped_iframe
|
||||||
@ -396,8 +396,7 @@ class Editor:
|
|||||||
self.pending_set_html = html
|
self.pending_set_html = html
|
||||||
return
|
return
|
||||||
rgba = get_color_as_rgba('window-foreground')
|
rgba = get_color_as_rgba('window-foreground')
|
||||||
cs = 'dark' if browser_in_dark_mode() else 'light'
|
self.iframe_wrapper.send_message('set_html', html=html, color_scheme=color_scheme(), color=f'rgba({rgba[0]},{rgba[1]},{rgba[2]},{rgba[3]})')
|
||||||
self.iframe_wrapper.send_message('set_html', html=html, color_scheme=cs, color=f'rgba({rgba[0]},{rgba[1]},{rgba[2]},{rgba[3]})')
|
|
||||||
|
|
||||||
def get_html(self, proceed):
|
def get_html(self, proceed):
|
||||||
self.get_html_callbacks.push(proceed)
|
self.get_html_callbacks.push(proceed)
|
||||||
|
@ -81,6 +81,10 @@ def browser_in_dark_mode():
|
|||||||
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
return window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||||
|
|
||||||
|
|
||||||
|
def color_scheme():
|
||||||
|
return 'dark' if browser_in_dark_mode() or document.documentElement.style.colorScheme is 'dark' else 'light'
|
||||||
|
|
||||||
|
|
||||||
def css_for_variables():
|
def css_for_variables():
|
||||||
input_css = '''
|
input_css = '''
|
||||||
input, textarea {
|
input, textarea {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user