prometheus/web/ui/react-app/src/contexts/ThemeContext.tsx
cui fliter 484a9e4071
fix some typos (#12498)
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-06-29 12:28:13 +02:00

23 lines
582 B
TypeScript

import React from 'react';
export type themeName = 'light' | 'dark';
export type themeSetting = themeName | 'auto';
export interface ThemeCtx {
theme: themeName;
userPreference: themeSetting;
setTheme: (t: themeSetting) => void;
}
// defaults, will be overridden in App.tsx
export const ThemeContext = React.createContext<ThemeCtx>({
theme: 'light',
userPreference: 'auto',
// eslint-disable-next-line @typescript-eslint/no-empty-function
setTheme: (s: themeSetting) => {},
});
export const useTheme = (): ThemeCtx => {
return React.useContext(ThemeContext);
};