release nouri 0.3 household sharing and mobile polish
This commit is contained in:
+10
-12
@@ -1,7 +1,7 @@
|
||||
(() => {
|
||||
const root = document.documentElement;
|
||||
const storageKey = "nouri-theme";
|
||||
const toggle = () => document.querySelector("[data-theme-toggle]");
|
||||
const toggles = () => Array.from(document.querySelectorAll("[data-theme-toggle]"));
|
||||
|
||||
const applyTheme = (theme) => {
|
||||
const resolved = theme || localStorage.getItem(storageKey) || "auto";
|
||||
@@ -11,22 +11,20 @@
|
||||
: resolved;
|
||||
root.dataset.theme = finalTheme;
|
||||
|
||||
const button = toggle();
|
||||
if (button) {
|
||||
toggles().forEach((button) => {
|
||||
button.textContent = finalTheme === "dark" ? "Hell" : "Dunkel";
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
applyTheme();
|
||||
const button = toggle();
|
||||
if (!button) return;
|
||||
|
||||
button.addEventListener("click", () => {
|
||||
const current = root.dataset.theme === "dark" ? "dark" : "light";
|
||||
const next = current === "dark" ? "light" : "dark";
|
||||
localStorage.setItem(storageKey, next);
|
||||
applyTheme(next);
|
||||
toggles().forEach((button) => {
|
||||
button.addEventListener("click", () => {
|
||||
const current = root.dataset.theme === "dark" ? "dark" : "light";
|
||||
const next = current === "dark" ? "light" : "dark";
|
||||
localStorage.setItem(storageKey, next);
|
||||
applyTheme(next);
|
||||
});
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user