github.com/kyleu/dbaudit@v0.0.2-0.20240321155047-ff2f2c940496/client/src/mode.ts (about)

     1  // Content managed by Project Forge, see [projectforge.md] for details.
     2  import {els} from "./dom";
     3  
     4  const l = "mode-light";
     5  const d = "mode-dark";
     6  
     7  export function modeInit() {
     8    for (const el of els<HTMLInputElement>(".mode-input")) {
     9      el.onclick = () => {
    10        switch (el.value) {
    11          case "":
    12            document.body.classList.remove(l);
    13            document.body.classList.remove(d);
    14            break;
    15          case "light":
    16            document.body.classList.add(l);
    17            document.body.classList.remove(d);
    18            break;
    19          case "dark":
    20            document.body.classList.remove(l);
    21            document.body.classList.add(d);
    22            break;
    23        }
    24      };
    25    }
    26  }