mirror of
https://github.com/priyanshujain/margin.git
synced 2026-10-02 19:17:03 +00:00
feat(theme): persistent light/dark toggle in the titlebar
This commit is contained in:
1 parent
a5b3c0c0e3
commit
9991d318ba
5 files changed
+61
-3
No files matched your search
@@ -0,0 +1,16 @@
|
||||
import { create } from "zustand";
|
||||
import { applyTheme, initialTheme, type Theme } from "../theme";
|
||||
|
||||
interface ThemeState {
|
||||
theme: Theme;
|
||||
toggle: () => void;
|
||||
}
|
||||
|
||||
export const useTheme = create<ThemeState>((set, get) => ({
|
||||
theme: initialTheme(),
|
||||
toggle: () => {
|
||||
const next: Theme = get().theme === "dark" ? "light" : "dark";
|
||||
applyTheme(next);
|
||||
set({ theme: next });
|
||||
},
|
||||
}));
|
||||
Reference in new issue
Block a user