mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-05 16:33:36 +00:00
Refactor AppProvider
This commit is contained in:
9 files changed
+156
-204
No files matched your search
+18
-4
@@ -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,
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user