mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2025-04-27 06:18:27 -04:00
17 lines
623 B
TypeScript
17 lines
623 B
TypeScript
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);
|