Refactor AppProvider

This commit is contained in:
Alex Gleason committed 2025-06-04 10:06:38 -05:00
1 parent c3310ab485
commit 3ad83cd114
9 files changed
+156 -204

No files matched your search

+18 -4
View File
@@ -1,6 +1,20 @@
import { useTheme as useThemeFromProvider } from "@/components/AppProvider";
import { type Theme } from "@/contexts/AppContext";
import { useAppConfig } from "@/hooks/useAppConfig";
/** Hook to get and set the active theme. */
export function useTheme() {
return useThemeFromProvider();
/**
* Hook to get and set the active theme
* @returns Theme context with theme and setTheme
*/
export function useTheme(): { theme: Theme; setTheme: (theme: Theme) => void } {
const { config, updateConfig } = useAppConfig();
return {
theme: config.theme,
setTheme: (theme: Theme) => {
updateConfig((currentConfig) => ({
...currentConfig,
theme,
}));
}
}
}