mirror of
https://codeberg.org/vlw/victorwesterlund.com.git
synced 2025-09-14 11:33:41 +02:00
22 lines
No EOL
607 B
JavaScript
22 lines
No EOL
607 B
JavaScript
// Copyright © Victor Westerlund - No libraries! 😲
|
|
import { default as Interaction } from "./modules/UI.mjs";
|
|
|
|
const theme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
const main = new Interaction();
|
|
|
|
function updateTheme() {
|
|
const media = window.matchMedia("(prefers-color-scheme: dark)");
|
|
document.body.classList.remove("dark");
|
|
|
|
// Force dark theme on all pages
|
|
if(media.matches) {
|
|
document.body.classList.add("dark");
|
|
return;
|
|
}
|
|
|
|
main.setThemeColor("background");
|
|
}
|
|
|
|
// Set the current page theme, and listen for changes
|
|
theme.addEventListener("change",updateTheme);
|
|
updateTheme(); |