Simplify conditionals

This commit is contained in:
nickofolas 2022-05-02 11:38:20 -05:00
parent d4f3128829
commit 762acfb7b5

@ -116,11 +116,23 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
}}
>
{flatGrid.map((item) => {
const color = item.current
? Settings.theme.infolight
: item.marked
? Settings.theme.warning
: Settings.theme.error;
let color: string;
let icon: React.ReactElement;
if (item.marked) {
color = Settings.theme.warning;
icon = <Flag />;
} else if (item.current) {
color = Settings.theme.infolight;
icon = <Close />;
} else if (item.flagged) {
color = Settings.theme.error;
icon = <Report />;
} else {
color = Settings.theme.primary;
icon = <></>;
}
return (
<Typography
key={`${item}${uniqueId()}`}
@ -134,7 +146,7 @@ export function MinesweeperGame(props: IMinigameProps): React.ReactElement {
justifyContent: "center",
}}
>
{item.current ? <Close /> : item.flagged ? <Report /> : item.marked ? <Flag /> : <></>}
{icon}
</Typography>
);
})}