Merge pull request #2229 from FaintSpeaker/update-theme-engine-missing-elements

Update theme engine to cover some themeless elements
This commit is contained in:
hydroflame 2022-01-08 14:13:53 -05:00 committed by GitHub
commit 20ca1239df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 48 additions and 9 deletions

@ -17,11 +17,27 @@ import { IRouter } from "../../ui/Router";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button"; import Button from "@mui/material/Button";
import { LocationType } from "../LocationTypeEnum"; import { LocationType } from "../LocationTypeEnum";
import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
type IProps = { type IProps = {
city: City; city: City;
}; };
const useStyles = makeStyles((theme: Theme) =>
createStyles({
location: {
color: theme.colors.white,
whiteSpace: "nowrap",
margin: "0px",
padding: "0px",
cursor: "pointer",
},
})
);
function toLocation(router: IRouter, location: Location): void { function toLocation(router: IRouter, location: Location): void {
if (location.name === LocationName.TravelAgency) { if (location.name === LocationName.TravelAgency) {
router.toTravel(); router.toTravel();
@ -35,6 +51,7 @@ function toLocation(router: IRouter, location: Location): void {
function LocationLetter(location: Location): React.ReactElement { function LocationLetter(location: Location): React.ReactElement {
location.types; location.types;
const router = use.Router(); const router = use.Router();
const classes = useStyles();
let L = "X"; let L = "X";
if (location.types.includes(LocationType.Company)) L = "C"; if (location.types.includes(LocationType.Company)) L = "C";
if (location.types.includes(LocationType.Gym)) L = "G"; if (location.types.includes(LocationType.Gym)) L = "G";
@ -51,13 +68,7 @@ function LocationLetter(location: Location): React.ReactElement {
<span <span
aria-label={location.name} aria-label={location.name}
key={location.name} key={location.name}
style={{ className={classes.location}
color: "white",
whiteSpace: "nowrap",
margin: "0px",
padding: "0px",
cursor: "pointer",
}}
onClick={() => toLocation(router, location)} onClick={() => toLocation(router, location)}
> >
<b>{L}</b> <b>{L}</b>

@ -21,6 +21,8 @@ declare module "@mui/material/styles" {
successlight: React.CSSProperties["color"]; successlight: React.CSSProperties["color"];
success: React.CSSProperties["color"]; success: React.CSSProperties["color"];
successdark: React.CSSProperties["color"]; successdark: React.CSSProperties["color"];
white: React.CSSProperties["color"];
black: React.CSSProperties["color"];
}; };
} }
interface ThemeOptions { interface ThemeOptions {
@ -38,6 +40,8 @@ declare module "@mui/material/styles" {
successlight: React.CSSProperties["color"]; successlight: React.CSSProperties["color"];
success: React.CSSProperties["color"]; success: React.CSSProperties["color"];
successdark: React.CSSProperties["color"]; successdark: React.CSSProperties["color"];
white: React.CSSProperties["color"];
black: React.CSSProperties["color"];
}; };
} }
} }
@ -60,6 +64,8 @@ export function refreshTheme(): void {
successlight: Settings.theme.successlight, successlight: Settings.theme.successlight,
success: Settings.theme.success, success: Settings.theme.success,
successdark: Settings.theme.successdark, successdark: Settings.theme.successdark,
white: Settings.theme.white,
black: Settings.theme.black,
}, },
palette: { palette: {
primary: { primary: {
@ -87,6 +93,11 @@ export function refreshTheme(): void {
main: Settings.theme.warning, main: Settings.theme.warning,
dark: Settings.theme.warningdark, dark: Settings.theme.warningdark,
}, },
success: {
light: Settings.theme.successlight,
main: Settings.theme.success,
dark: Settings.theme.successdark,
},
background: { background: {
default: Settings.theme.backgroundprimary, default: Settings.theme.backgroundprimary,
paper: Settings.theme.well, paper: Settings.theme.well,
@ -320,7 +331,7 @@ export function refreshTheme(): void {
border: "1px solid " + Settings.theme.well, border: "1px solid " + Settings.theme.well,
}, },
standardSuccess: { standardSuccess: {
color: Settings.theme.primarylight, color: Settings.theme.successlight,
}, },
standardError: { standardError: {
color: Settings.theme.errorlight, color: Settings.theme.errorlight,
@ -335,6 +346,8 @@ export function refreshTheme(): void {
}, },
}, },
}); });
document.body.style.backgroundColor = theme.colors.black?.toString() ?? "black";
} }
refreshTheme(); refreshTheme();

@ -2,6 +2,9 @@ import React from "react";
import { CityName } from "../../Locations/data/CityNames"; import { CityName } from "../../Locations/data/CityNames";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import Tooltip from "@mui/material/Tooltip"; import Tooltip from "@mui/material/Tooltip";
import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
interface ICityProps { interface ICityProps {
currentCity: CityName; currentCity: CityName;
@ -9,13 +12,25 @@ interface ICityProps {
onTravel: (city: CityName) => void; onTravel: (city: CityName) => void;
} }
const useStyles = makeStyles((theme: Theme) =>
createStyles({
travel: {
color: theme.colors.white,
lineHeight: "1em",
whiteSpace: "pre",
cursor: "pointer"
},
})
);
function City(props: ICityProps): React.ReactElement { function City(props: ICityProps): React.ReactElement {
const classes = useStyles();
if (props.city !== props.currentCity) { if (props.city !== props.currentCity) {
return ( return (
<Tooltip title={<Typography>{props.city}</Typography>}> <Tooltip title={<Typography>{props.city}</Typography>}>
<span <span
onClick={() => props.onTravel(props.city)} onClick={() => props.onTravel(props.city)}
style={{ color: "white", lineHeight: "1em", whiteSpace: "pre", cursor: "pointer" }} className={classes.travel}
> >
{props.city[0]} {props.city[0]}
</span> </span>