github.com/wfusion/gofusion@v1.1.14/common/infra/asynq/asynqmon/ui/src/theme.tsx (about)

     1  import { createTheme, Theme } from "@material-ui/core/styles";
     2  import { ThemePreference } from "./reducers/settingsReducer";
     3  import useMediaQuery from "@material-ui/core/useMediaQuery";
     4  
     5  export function useTheme(themePreference: ThemePreference): Theme {
     6    let prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
     7    if (themePreference === ThemePreference.Always) {
     8      prefersDarkMode = true;
     9    } else if (themePreference === ThemePreference.Never) {
    10      prefersDarkMode = false;
    11    }
    12    return createTheme({
    13      // Got color palette from https://htmlcolors.com/palette/31/stripe
    14      palette: {
    15        primary: {
    16          main: "#4379FF",
    17        },
    18        secondary: {
    19          main: "#97FBD1",
    20        },
    21        background: {
    22          default: "#f5f7f9",
    23        },
    24        type: prefersDarkMode ? "dark" : "light",
    25      },
    26    });
    27  }
    28  
    29  export function isDarkTheme(theme: Theme): boolean {
    30    return theme.palette.type === "dark";
    31  }