app first commit

This commit is contained in:
Alessio Ganzarolli 2025-08-02 02:08:59 +02:00
parent 0e16d3e6be
commit 4441012687
45 changed files with 12987 additions and 0 deletions

View file

@ -0,0 +1,28 @@
// src/hooks/useTheme.ts
import { useEffect } from "react";
import { useAtom } from "jotai";
import { themeAtom } from "../atoms";
const ALL_THEMES = ["light", "dark", "red"];
export function useTheme() {
const [theme, setTheme] = useAtom(themeAtom);
useEffect(() => {
const body = document.body;
ALL_THEMES.forEach((t) => body.classList.remove(t));
body.classList.add(theme);
console.log('set ', theme)
}, [theme]);
const toggleTheme = () => {
setTheme((prev) => (prev === "light" ? "dark" : "light"));
};
return {
theme,
setTheme,
toggleTheme,
themes: ALL_THEMES,
};
}