wip media query rework, sidebar mostly finished, rewritten njk
This commit is contained in:
parent
cb5ba4fb82
commit
790147ea05
33 changed files with 268 additions and 361 deletions
|
|
@ -1,24 +1,26 @@
|
|||
const basePath = "/assets/css";
|
||||
const themeToggle = document.getElementById("theme-toggle");
|
||||
const themeToggles = document.querySelectorAll(".theme-toggle");
|
||||
const themeStylesheet = document.getElementById("themed");
|
||||
|
||||
const themes = [
|
||||
{ name: "system", file: "default/system.css" },
|
||||
{ name: "citrus", file: "citrus/default.css" },
|
||||
{ name: "system", file: "default/system.css" },
|
||||
{ name: "citrus", file: "citrus/default.css" },
|
||||
];
|
||||
|
||||
let currentTheme = localStorage.getItem("theme") || themes[0].name;
|
||||
setTheme(currentTheme);
|
||||
|
||||
function setTheme(themeName) {
|
||||
const theme = themes.find(t => t.name === themeName);
|
||||
if (theme) {
|
||||
themeStylesheet.href = `${basePath}/${theme.file}`;
|
||||
}
|
||||
const theme = themes.find(t => t.name === themeName);
|
||||
if (theme && themeStylesheet) {
|
||||
themeStylesheet.href = `${basePath}/${theme.file}`;
|
||||
}
|
||||
}
|
||||
|
||||
themeToggle.addEventListener("click", () => {
|
||||
currentTheme = themes[(themes.findIndex(t => t.name === currentTheme) + 1) % themes.length].name;
|
||||
setTheme(currentTheme);
|
||||
localStorage.setItem("theme", currentTheme);
|
||||
});
|
||||
themeToggles.forEach(btn =>
|
||||
btn.addEventListener("click", () => {
|
||||
currentTheme = themes[(themes.findIndex(t => t.name === currentTheme) + 1) % themes.length].name;
|
||||
setTheme(currentTheme);
|
||||
localStorage.setItem("theme", currentTheme);
|
||||
})
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue