AniX/frontend/app/store/theme-store.js

20 lines
418 B
JavaScript

"use client";
import { create } from "zustand";
export function setTheme(theme) {
localStorage.setItem("theme", theme);
}
export function getTheme() {
return localStorage.getItem("theme");
}
export const useThemeStore = create((set) => ({
theme: "light",
changeTheme: (theme) => {
set({ theme: theme });
setTheme(theme);
},
checkTheme: () => {
set({ theme: getTheme() || "light" });
}
}));