1
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:
2022-04-08 12:36:19 -04:00
parent a8c1a3ba3c
commit d09cf7ab26
6 changed files with 56 additions and 64 deletions

View File

@ -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);