mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-06-30 22:26:38 -04:00
consolidate theme context/provider types
This commit is contained in:
@ -1,16 +1,5 @@
|
||||
import { useContext } from "react";
|
||||
import { ThemeContext } from "../contexts/ThemeContext";
|
||||
|
||||
export interface UseThemeProps {
|
||||
/** List of all available theme names */
|
||||
themes: string[];
|
||||
/** Active theme name */
|
||||
theme?: string;
|
||||
/** If the active theme is "system", this returns whether the system preference resolved to "dark" or "light". Otherwise, identical to `theme` */
|
||||
resolvedTheme?: string;
|
||||
/** Update the theme */
|
||||
setTheme: (theme: string) => void;
|
||||
}
|
||||
|
||||
// useTheme() function to get current theme state from pages/components/etc.
|
||||
export const useTheme = (): UseThemeProps => useContext(ThemeContext);
|
||||
// convenience hook to get access to ThemeContext's state/functions from pages/components/etc.
|
||||
export const useTheme = () => useContext(ThemeContext);
|
||||
|
Reference in New Issue
Block a user