frontend: add color theme & theme switcher

This commit is contained in:
Kentai Radiquum 2024-04-19 22:58:45 +05:00
parent 84b13a2c80
commit b8878c4fb8
Signed by: Radiquum
GPG key ID: 858E8EE696525EED
7 changed files with 192 additions and 19 deletions

View file

@ -0,0 +1,20 @@
"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" });
}
}));