Add rating algorithm tooltips

This commit is contained in:
zkldi
2022-02-09 02:58:06 +00:00
parent 40fcf3d0f6
commit 9dfb92d087
4 changed files with 59 additions and 11 deletions
@@ -1,13 +1,24 @@
import ClassBadge from "components/game/ClassBadge";
import QuickTooltip from "components/layout/misc/QuickTooltip";
import MiniTable from "components/tables/components/MiniTable";
import Divider from "components/util/Divider";
import Icon from "components/util/Icon";
import React from "react";
import { GetGamePTConfig, IDStrings, ScoreCalculatedDataLookup, UserGameStats } from "tachi-common";
import {
GetGamePTConfig,
IDStrings,
ScoreCalculatedDataLookup,
UGSRatingsLookup,
UserGameStats,
} from "tachi-common";
import { GameClassSets } from "tachi-common/js/game-classes";
import { FormatGPTRating, UppercaseFirst } from "util/misc";
export default function UGPTRatingsTable({ ugs }: { ugs: UserGameStats }) {
const gptConfig = GetGamePTConfig(ugs.game, ugs.playtype);
const ratings = Object.entries(ugs.ratings) as [UGSRatingsLookup[IDStrings], number][];
return (
<MiniTable className="table-sm text-center" headers={["Player Stats"]} colSpan={2}>
<>
@@ -32,9 +43,34 @@ export default function UGPTRatingsTable({ ugs }: { ugs: UserGameStats }) {
</tr>
)
)}
{Object.entries(ugs.ratings).map(([k, v]) => (
{ratings.map(([k, v]) => (
<tr key={k}>
<td>{UppercaseFirst(k)}</td>
<td>
<QuickTooltip
tooltipContent={
<div>
{gptConfig.profileRatingAlgDescriptions[k]}
{k in gptConfig.scoreRatingAlgDescriptions && (
<>
<Divider />({UppercaseFirst(k)}:{" "}
{/* @ts-expect-error I know better. */}
{gptConfig.scoreRatingAlgDescriptions[k]})
</>
)}
</div>
}
wide
>
<div
style={{
textDecoration: "underline",
textDecorationStyle: "dotted",
}}
>
{UppercaseFirst(k)}
</div>
</QuickTooltip>
</td>
<td>
{FormatGPTRating(
ugs.game,