mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
Set night-mode class on web page initialization
Ensures the background is the correct color by the time the webview is shown. We keep the #night check for now, as it's useful when testing in an external browser.
This commit is contained in:
parent
1870253589
commit
93d14de95c
1 changed files with 5 additions and 0 deletions
|
@ -664,6 +664,10 @@ html {{ {font} }}
|
|||
gui_hooks.webview_did_inject_style_into_page(self)
|
||||
self.show()
|
||||
|
||||
if theme_manager.night_mode:
|
||||
night_mode = 'document.documentElement.classList.add("night-mode");'
|
||||
else:
|
||||
night_mode = ""
|
||||
self.evalWithCallback(
|
||||
f"""
|
||||
(function(){{
|
||||
|
@ -671,6 +675,7 @@ html {{ {font} }}
|
|||
style.innerHTML = `{css}`;
|
||||
document.head.appendChild(style);
|
||||
document.body.classList.add({", ".join([f'"{c}"' for c in body_classes])});
|
||||
{night_mode}
|
||||
}})();
|
||||
""",
|
||||
after_injection,
|
||||
|
|
Loading…
Reference in a new issue