JS: Add a setOption handler that can toggle the bg/background option

This commit is contained in:
Eryn Wells 2024-08-08 10:23:43 -10:00
parent de6342b05c
commit efd5f8991d

16
assets/js/commands.js Normal file
View file

@ -0,0 +1,16 @@
document.addEventListener("DOMContentLoaded", () => {
const commandBar = document.querySelector("command-bar");
commandBar.addEventListener("setOption", event => {
console.log("SetOption", event);
switch (event.option) {
case "bg":
case "background":
const value = event.newValue;
if (value === "dark" || value === "light") {
document.querySelector(":root").setAttribute("color-scheme", value);
}
break;
}
});
});