github.com/thanos-io/thanos@v0.32.5/pkg/ui/react-app/src/contexts/ThemeContext.tsx (about)

     1  /*
     2   *
     3   * THIS FILE WAS COPIED INTO THANOS FROM PROMETHEUS
     4   * (LIVING AT https://github.com/prometheus/prometheus/blob/main/web/ui/react-app/src/contexts/ThemeContext.tsx),
     5   * THE ORIGINAL CODE WAS LICENSED UNDER AN APACHE 2.0 LICENSE, SEE
     6   * https://github.com/prometheus/prometheus/blob/main/LICENSE.
     7   *
     8   */
     9  
    10  import React from 'react';
    11  
    12  export type themeName = 'light' | 'dark';
    13  export type themeSetting = themeName | 'auto';
    14  
    15  export interface ThemeCtx {
    16    theme: themeName;
    17    userPreference: themeSetting;
    18    setTheme: (t: themeSetting) => void;
    19  }
    20  
    21  // defaults, will be overridden in App.tsx
    22  export const ThemeContext = React.createContext<ThemeCtx>({
    23    theme: 'light',
    24    userPreference: 'auto',
    25    // eslint-disable-next-line @typescript-eslint/no-empty-function
    26    setTheme: (s: themeSetting) => {},
    27  });
    28  
    29  export const useTheme = () => {
    30    return React.useContext(ThemeContext);
    31  };