receipts/js/common.ts

21 lines
609 B
TypeScript

import "@shoelace-style/shoelace/dist/themes/light.css";
import "@shoelace-style/shoelace/dist/themes/dark.css";
import "./common.css";
const mql = window.matchMedia("(prefers-color-scheme: dark");
const setDarkMode = () => {
if (mql.matches) {
document.documentElement.classList.add("sl-theme-dark");
} else {
document.documentElement.classList.remove("sl-theme-dark");
}
};
mql.addEventListener("change", setDarkMode);
setDarkMode();
document.addEventListener("DOMContentLoaded", () => {
const elm = document.getElementById("page-loading");
if (elm) elm.remove();
});