main.js: Improve dark mode
Make use of the [`color-scheme` meta tag][0] to style buttons and other widgets to match the selected color scheme. When the scheme is toggled, the `content` of the tag is set to "light" or "dark" to tell the user agent how to theme input elements, which should match the colors of the rest of the app. [0]: https://html.spec.whatwg.org/multipage/semantics.html#meta-color-scheme
This commit is contained in:
parent
f3f22fb884
commit
615dcd5f89
@ -338,6 +338,12 @@ class ThemeToggler extends HTMLAnchorElement {
|
||||
this.innerText = "◑";
|
||||
this.setAttribute("aria-hidden", "true");
|
||||
this.style.cursor = "pointer";
|
||||
|
||||
// Add color-scheme meta tag to style buttons
|
||||
const colorSchemeMeta = document.createElement("meta");
|
||||
colorSchemeMeta.name = "color-scheme";
|
||||
colorSchemeMeta.content = this.theme;
|
||||
document.head.appendChild(colorSchemeMeta);
|
||||
}
|
||||
|
||||
click() {
|
||||
@ -369,6 +375,7 @@ class ThemeToggler extends HTMLAnchorElement {
|
||||
$(".corner .bordered").style.border = "1px solid black";
|
||||
$$("a").forEach((e) => { e.style.color = "black" });
|
||||
}
|
||||
$("meta[name=color-scheme]").content = this.theme;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user