feat: migrate to vue 3 (#2689)

---------

Co-authored-by: Joep <jcbuhre@gmail.com>
Co-authored-by: Omar Hussein <omarmohammad1951@gmail.com>
Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
This commit is contained in:
authored and GitHub committed 2024-04-01 17:18:22 +02:00
1 parent 0e3b35b30e
commit 5100e587d7
164 files changed
+12202 -8047

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import { theme } from "./constants";
export const getTheme = (): UserTheme => {
return (document.documentElement.className as UserTheme) || theme;
};
export const setTheme = (theme: UserTheme) => {
const html = document.documentElement;
if (!theme) {
html.className = getMediaPreference();
} else {
html.className = theme;
}
};
export const toggleTheme = (): void => {
const activeTheme = getTheme();
if (activeTheme === "light") {
setTheme("dark");
} else {
setTheme("light");
}
};
export const getMediaPreference = (): UserTheme => {
const hasDarkPreference = window.matchMedia(
"(prefers-color-scheme: dark)"
).matches;
if (hasDarkPreference) {
return "dark";
} else {
return "light";
}
};