bitburner-src/src/ui/React/Theme.tsx

305 lines
6.7 KiB
TypeScript
Raw Normal View History

2021-09-13 18:44:46 +02:00
import React from "react";
2021-09-18 01:43:08 +02:00
import { createTheme, ThemeProvider, Theme, StyledEngineProvider } from "@mui/material/styles";
2021-09-17 01:23:03 +02:00
2021-09-21 02:42:13 +02:00
declare module "@mui/material/styles" {
interface Theme {
colors: {
hp: React.CSSProperties["color"];
money: React.CSSProperties["color"];
hack: React.CSSProperties["color"];
combat: React.CSSProperties["color"];
cha: React.CSSProperties["color"];
int: React.CSSProperties["color"];
rep: React.CSSProperties["color"];
};
}
interface ThemeOptions {
colors: {
hp: React.CSSProperties["color"];
money: React.CSSProperties["color"];
hack: React.CSSProperties["color"];
combat: React.CSSProperties["color"];
cha: React.CSSProperties["color"];
int: React.CSSProperties["color"];
rep: React.CSSProperties["color"];
};
}
2021-09-17 01:23:03 +02:00
}
2021-09-21 19:08:05 +02:00
export let colors = {
2021-09-13 23:11:02 +02:00
primarylight: "#0f0",
primary: "#0c0",
2021-09-13 18:44:46 +02:00
primarydark: "#090",
2021-09-14 20:10:59 +02:00
errorlight: "#f00",
error: "#c00",
errordark: "#900",
secondarylight: "#AAA",
secondary: "#888",
secondarydark: "#666",
2021-09-18 03:30:02 +02:00
warninglight: "#ff0",
warning: "#cc0",
warningdark: "#990",
2021-09-18 06:16:02 +02:00
infolight: "#69f",
info: "#36c",
infodark: "#039",
2021-09-15 03:05:49 +02:00
welllight: "#444",
2021-09-13 23:11:02 +02:00
well: "#222",
2021-09-14 20:10:59 +02:00
white: "#fff",
black: "#000",
2021-09-16 23:30:47 +02:00
hp: "#dd3434",
money: "#ffd700",
hack: "#adff2f",
combat: "#faffdf",
cha: "#a671d1",
int: "#6495ed",
2021-09-21 02:42:13 +02:00
rep: "#faffdf",
2021-09-13 18:44:46 +02:00
};
2021-09-22 02:30:00 +02:00
let theme: Theme;
2021-09-21 19:08:05 +02:00
2021-09-22 02:30:00 +02:00
function refreshTheme() {
2021-09-21 19:08:05 +02:00
theme = createTheme({
colors: {
hp: "#dd3434",
money: "#ffd700",
hack: "#adff2f",
combat: "#faffdf",
cha: "#a671d1",
int: "#6495ed",
rep: "#faffdf",
2021-09-18 03:30:02 +02:00
},
2021-09-21 19:08:05 +02:00
palette: {
primary: {
light: colors.primarylight,
main: colors.primary,
dark: colors.primarydark,
},
secondary: {
light: colors.secondarylight,
main: colors.secondary,
dark: colors.secondarydark,
},
error: {
light: colors.errorlight,
main: colors.error,
dark: colors.errordark,
},
info: {
light: colors.infolight,
main: colors.info,
dark: colors.infodark,
},
warning: {
light: colors.warninglight,
main: colors.warning,
dark: colors.warningdark,
},
background: {
default: colors.black,
paper: colors.well,
},
2021-09-15 03:05:49 +02:00
},
2021-09-21 19:08:05 +02:00
typography: {
fontFamily: "monospace",
button: {
textTransform: "none",
},
2021-09-13 18:44:46 +02:00
},
2021-09-21 19:08:05 +02:00
components: {
MuiInputBase: {
styleOverrides: {
root: {
backgroundColor: colors.well,
color: colors.primary,
},
input: {
"&::placeholder": {
userSelect: "none",
color: colors.primarydark,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
},
2021-09-17 01:23:03 +02:00
2021-09-21 19:08:05 +02:00
MuiInput: {
styleOverrides: {
root: {
backgroundColor: colors.well,
borderBottomColor: "#fff",
2021-09-17 01:23:03 +02:00
},
2021-09-21 19:08:05 +02:00
underline: {
"&:hover": {
borderBottomColor: colors.primarydark,
},
"&:before": {
borderBottomColor: colors.primary,
},
"&:after": {
borderBottomColor: colors.primarylight,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
},
2021-09-17 01:23:03 +02:00
2021-09-21 19:08:05 +02:00
MuiInputLabel: {
styleOverrides: {
root: {
color: colors.primarydark, // why is this switched?
userSelect: "none",
"&:before": {
color: colors.primarylight,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
},
2021-09-21 19:08:05 +02:00
MuiButton: {
styleOverrides: {
root: {
backgroundColor: "#333",
border: "1px solid " + colors.well,
// color: colors.primary,
"&:hover": {
backgroundColor: colors.black,
},
2021-09-14 04:27:43 +02:00
2021-09-21 19:08:05 +02:00
borderRadius: 0,
},
2021-09-18 06:16:02 +02:00
},
},
2021-09-21 19:08:05 +02:00
MuiSelect: {
styleOverrides: {
icon: {
color: colors.primary,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
2021-09-21 19:08:05 +02:00
MuiMenu: {
styleOverrides: {
list: {
backgroundColor: colors.well,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
2021-09-21 19:08:05 +02:00
MuiMenuItem: {
styleOverrides: {
root: {
color: colors.primary,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
2021-09-21 19:08:05 +02:00
MuiAccordionSummary: {
styleOverrides: {
root: {
backgroundColor: "#111",
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
2021-09-21 19:08:05 +02:00
MuiAccordionDetails: {
styleOverrides: {
root: {
backgroundColor: colors.black,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 02:37:35 +02:00
},
2021-09-21 19:08:05 +02:00
MuiIconButton: {
styleOverrides: {
root: {
color: colors.primary,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 04:27:43 +02:00
},
2021-09-21 19:08:05 +02:00
MuiTooltip: {
styleOverrides: {
tooltip: {
fontSize: "1em",
color: colors.primary,
backgroundColor: colors.well,
borderRadius: 0,
border: "2px solid white",
maxWidth: "100vh",
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 04:27:43 +02:00
},
2021-09-21 19:08:05 +02:00
MuiSlider: {
styleOverrides: {
valueLabel: {
color: colors.primary,
backgroundColor: colors.well,
},
},
},
2021-09-21 19:08:05 +02:00
MuiDrawer: {
styleOverrides: {
paper: {
"&::-webkit-scrollbar": {
// webkit
display: "none",
},
scrollbarWidth: "none", // firefox
backgroundColor: colors.black,
},
paperAnchorDockedLeft: {
borderRight: "1px solid " + colors.welllight,
2021-09-17 01:23:03 +02:00
},
2021-09-14 20:10:59 +02:00
},
},
2021-09-21 19:08:05 +02:00
MuiDivider: {
styleOverrides: {
root: {
backgroundColor: colors.welllight,
},
2021-09-17 01:23:03 +02:00
},
2021-09-15 03:05:49 +02:00
},
2021-09-21 19:08:05 +02:00
MuiFormControlLabel: {
styleOverrides: {
root: {
color: colors.primary,
},
2021-09-17 01:23:03 +02:00
},
2021-09-15 03:05:49 +02:00
},
2021-09-21 19:08:05 +02:00
MuiSwitch: {
styleOverrides: {
switchBase: {
color: colors.primarydark,
},
track: {
backgroundColor: colors.welllight,
},
2021-09-17 01:23:03 +02:00
},
2021-09-14 20:10:59 +02:00
},
2021-09-21 19:08:05 +02:00
MuiPaper: {
styleOverrides: {
root: {
borderRadius: 0,
backgroundColor: colors.black,
border: "1px solid " + colors.welllight,
},
2021-09-17 01:23:03 +02:00
},
2021-09-16 23:30:47 +02:00
},
2021-09-21 19:08:05 +02:00
MuiTablePagination: {
styleOverrides: {
select: {
color: colors.primary,
},
2021-09-18 06:16:02 +02:00
},
},
},
2021-09-21 19:08:05 +02:00
});
}
refreshTheme();
2021-09-13 18:44:46 +02:00
interface IProps {
children: JSX.Element[] | JSX.Element;
}
2021-09-17 01:23:03 +02:00
export const TTheme = ({ children }: IProps): React.ReactElement => (
<StyledEngineProvider injectFirst>
<ThemeProvider theme={theme}>{children}</ThemeProvider>
</StyledEngineProvider>
2021-09-13 18:44:46 +02:00
);