asynqmon/ui/src/theme.tsx

28 lines
836 B
TypeScript
Raw Normal View History

2021-01-13 07:55:56 +08:00
import { createMuiTheme, Theme } from "@material-ui/core/styles";
import { ThemePreference } from "./reducers/settingsReducer";
import useMediaQuery from "@material-ui/core/useMediaQuery";
2020-11-24 22:54:00 +08:00
export function useTheme(themePreference: ThemePreference): Theme {
let prefersDarkMode = useMediaQuery("(prefers-color-scheme: dark)");
if (themePreference === ThemePreference.Always) {
prefersDarkMode = true;
} else if (themePreference === ThemePreference.Never) {
prefersDarkMode = false;
}
2021-01-13 07:55:56 +08:00
return createMuiTheme({
// Got color palette from https://htmlcolors.com/palette/31/stripe
palette: {
primary: {
main: "#4379FF",
},
secondary: {
main: "#97FBD1",
},
background: {
default: "#f5f7f9",
},
type: prefersDarkMode ? "dark" : "light",
2020-11-24 22:54:00 +08:00
},
2021-01-13 07:55:56 +08:00
});
}