feat: updated app to tailwind 4.x

This commit is contained in:
Dan Ditomaso
2025-02-20 15:56:51 -05:00
parent 39c1176311
commit b959a59e7b
56 changed files with 1096 additions and 1299 deletions
+37
View File
@@ -0,0 +1,37 @@
import { useEffect, useState } from "react";
type Theme = "light" | "dark";
export function useTheme() {
const [theme, setTheme] = useState<Theme>(() => {
if (typeof window === "undefined") return "light";
return (
(document.documentElement.getAttribute("data-theme") as Theme) || "light"
);
});
useEffect(() => {
const observer = new MutationObserver((mutations) => {
for (const mutation of mutations) {
if (
mutation.type === "attributes" &&
mutation.attributeName === "data-theme"
) {
const newTheme = document.documentElement.getAttribute(
"data-theme",
) as Theme;
setTheme(newTheme);
}
}
});
observer.observe(document.documentElement, {
attributes: true,
attributeFilter: ["data-theme"],
});
return () => observer.disconnect();
}, []);
return theme;
}