mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 17:53:00 +02:00
Implement common stats row element
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
import React from "react";
|
||||
|
||||
import {
|
||||
Typography,
|
||||
TableCell,
|
||||
TableRow,
|
||||
} from "@mui/material";
|
||||
|
||||
import { numeralWrapper } from "../numeralFormat";
|
||||
import { formatNumber } from "../../utils/StringHelperFunctions";
|
||||
import { characterOverviewStyles as useStyles } from "./CharacterOverview";
|
||||
|
||||
interface ITableRowData {
|
||||
content?: string;
|
||||
level?: number;
|
||||
exp?: number;
|
||||
}
|
||||
|
||||
interface IProps {
|
||||
name: string;
|
||||
color: string;
|
||||
classes?: any;
|
||||
data: ITableRowData;
|
||||
}
|
||||
|
||||
export const StatsRow = ({ name, color, classes = useStyles(), data }: IProps): React.ReactElement => {
|
||||
let content;
|
||||
|
||||
if (data.content !== undefined) {
|
||||
content = data.content;
|
||||
} else if (data.level !== undefined && data.exp !== undefined) {
|
||||
content = `${formatNumber(data.level, 0)} (${numeralWrapper.formatExp(data.exp)} exp)`;
|
||||
} else if (data.level !== undefined && data.exp === undefined) {
|
||||
content = `${formatNumber(data.level, 0)}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<TableRow>
|
||||
<TableCell classes={{ root: classes.cellNone }}>
|
||||
<Typography style={{ color: color }}>{name}</Typography>
|
||||
</TableCell>
|
||||
<TableCell align="right" classes={{ root: classes.cellNone }}>
|
||||
<Typography style={{ color: color }}>
|
||||
{content}
|
||||
</Typography>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user