inference-playground / src /lib /spells /is-dark.svelte.ts
Thomas G. Lopes
fix light theme in structured output
143859e
raw
history blame contribute delete
512 Bytes
import { createSubscriber } from "svelte/reactivity";
const subscribe = createSubscriber(update => {
const mutationObserver = new MutationObserver(entries => {
for (const entry of entries) {
if (entry.type === "attributes" && entry.attributeName === "class") {
update();
}
}
});
mutationObserver.observe(document.body, { attributes: true });
return () => {
mutationObserver.disconnect();
};
});
export function isDark() {
subscribe();
return document.body.classList.contains("dark");
}