mirror of
https://github.com/zadam/trilium.git
synced 2026-02-28 09:33:38 +01:00
Close #7932
This commit is contained in:
parent
6a3c4fec98
commit
44dc8cf00d
@ -34,6 +34,7 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
|
||||
window.visualViewport?.addEventListener("resize", () => this.#onMobileResize());
|
||||
}
|
||||
|
||||
this.#initTheme();
|
||||
this.#setDeviceSpecificClasses();
|
||||
this.#setMaxContentWidth();
|
||||
this.#setMotion();
|
||||
@ -67,6 +68,20 @@ export default class RootContainer extends FlexContainer<BasicWidget> {
|
||||
}
|
||||
}
|
||||
|
||||
#initTheme() {
|
||||
const colorSchemeChangeObserver = matchMedia("(prefers-color-scheme: dark)")
|
||||
colorSchemeChangeObserver.addEventListener("change", () => this.#updateColorScheme());
|
||||
|
||||
this.#updateColorScheme();
|
||||
}
|
||||
|
||||
#updateColorScheme() {
|
||||
const colorScheme = readCssVar(document.body, "theme-style").asString();
|
||||
|
||||
document.body.classList.toggle("light-theme", colorScheme === "light");
|
||||
document.body.classList.toggle("dark-theme", colorScheme === "dark");
|
||||
}
|
||||
|
||||
#onMobileResize() {
|
||||
const viewportHeight = window.visualViewport?.height ?? window.innerHeight;
|
||||
const windowHeight = Math.max(window.innerHeight, this.originalWindowHeight); // inner height changes when keyboard is opened, we need to compare with the original height to detect it.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user