mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
31 lines
792 B
TypeScript
31 lines
792 B
TypeScript
import { type Theme } from "@/contexts/AppContext";
|
|
import { useAppContext } from "@/hooks/useAppContext";
|
|
import { useSystemTheme } from "./useSystemTheme";
|
|
|
|
/**
|
|
* Hook to get and set the active theme
|
|
* @returns Theme context with theme and setTheme
|
|
*/
|
|
export function useTheme(): {
|
|
theme: Theme;
|
|
systemTheme: "light" | "dark";
|
|
displayTheme: "light" | "dark";
|
|
setTheme: (theme: Theme) => void;
|
|
} {
|
|
const { config, updateConfig } = useAppContext();
|
|
|
|
const systemTheme = useSystemTheme();
|
|
const displayTheme = config.theme === 'system' ? systemTheme : config.theme;
|
|
|
|
return {
|
|
theme: config.theme,
|
|
systemTheme,
|
|
displayTheme,
|
|
setTheme: (theme: Theme) => {
|
|
updateConfig((currentConfig) => ({
|
|
...currentConfig,
|
|
theme,
|
|
}));
|
|
}
|
|
}
|
|
} |