prometheus/web/ui/react-app/src/contexts/ThemeContext.tsx
Augustin Husson 5bcf2e6511 upgrade react-script to v4
Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
2021-09-04 15:56:36 +02:00

23 lines
581 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 overriden 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);
};