mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
23 lines
582 B
TypeScript
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);
|
|
};
|