mirror of https://github.com/VERT-sh/VERT.git
feat: dynamically lock dark reader
This commit is contained in:
parent
be2a248db0
commit
8437a9857d
|
@ -44,6 +44,13 @@
|
||||||
|
|
||||||
console.log(`Applying theme: ${theme}`);
|
console.log(`Applying theme: ${theme}`);
|
||||||
document.documentElement.classList.add(theme);
|
document.documentElement.classList.add(theme);
|
||||||
|
|
||||||
|
// Lock dark reader if it's set to dark mode
|
||||||
|
if (theme === "dark") {
|
||||||
|
const lock = document.createElement('meta');
|
||||||
|
lock.name = 'darkreader-lock';
|
||||||
|
document.head.appendChild(lock);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -215,6 +215,16 @@ export function setTheme(themeTo: "light" | "dark") {
|
||||||
});
|
});
|
||||||
log(["theme"], `set to ${themeTo}`);
|
log(["theme"], `set to ${themeTo}`);
|
||||||
theme.set(themeTo);
|
theme.set(themeTo);
|
||||||
|
|
||||||
|
// Lock dark reader if it's set to dark mode
|
||||||
|
if (themeTo === "dark") {
|
||||||
|
const lock = document.createElement('meta');
|
||||||
|
lock.name = 'darkreader-lock';
|
||||||
|
document.head.appendChild(lock);
|
||||||
|
} else {
|
||||||
|
const lock = document.querySelector('meta[name="darkreader-lock"]');
|
||||||
|
if (lock) lock.remove();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setEffects(effectsEnabled: boolean) {
|
export function setEffects(effectsEnabled: boolean) {
|
||||||
|
|
Loading…
Reference in New Issue