From a82616bd342a43198475478ec3ae7f5e89065154 Mon Sep 17 00:00:00 2001 From: Timothy Armes Date: Tue, 19 Sep 2023 10:09:21 +0200 Subject: [PATCH] Add a description of the k-factor --- app/[locale]/elo/KFactor.tsx | 54 ++++++++++++++++++++++++++++++ app/[locale]/elo/ManualEloForm.tsx | 4 +++ app/[locale]/elo/page.tsx | 45 ++++++++++++++----------- messages/en.json | 9 +++++ messages/fr.json | 17 +++++++--- 5 files changed, 105 insertions(+), 24 deletions(-) create mode 100644 app/[locale]/elo/KFactor.tsx diff --git a/app/[locale]/elo/KFactor.tsx b/app/[locale]/elo/KFactor.tsx new file mode 100644 index 0000000..20334cf --- /dev/null +++ b/app/[locale]/elo/KFactor.tsx @@ -0,0 +1,54 @@ +import { Disclosure } from "@headlessui/react"; +import { useTranslations } from "next-intl"; +import { IoChevronForward } from "react-icons/io5"; +import { twMerge } from "tailwind-merge"; + +type KFactorProps = { + className?: string; +}; + +export const KFactor = ({ className }: KFactorProps) => { + const t = useTranslations("Elo"); + + return ( + + + + {t("kFactorTitle")} + + + +

+ {t("kFactorInfo1")} +

+

+ {t("kFactorInfo2")} +

+ +
    + {( + [ + "kFactorInfo3", + "kFactorInfo4", + "kFactorInfo5", + "kFactorInfo6", + "kFactorInfo7", + ] as const + ).map((key) => ( +
  • + {t.rich(key, { b: (str) => {str} })} +
  • + ))} +
+
+
+ ); +}; diff --git a/app/[locale]/elo/ManualEloForm.tsx b/app/[locale]/elo/ManualEloForm.tsx index c56333f..5442371 100644 --- a/app/[locale]/elo/ManualEloForm.tsx +++ b/app/[locale]/elo/ManualEloForm.tsx @@ -12,6 +12,8 @@ import { SelectField } from "@/components/form/SelectField"; import { TextField } from "@/components/form/TextField"; import { getNewRating } from "@/utils/eloCalculator"; +import { KFactor } from "./KFactor"; + const resultsSchema = z.object({ currentElo: z.number().int().positive(), kFactor: z.enum(["40", "30", "20", "15", "10"]), @@ -122,6 +124,8 @@ export const ManualEloForm = () => { /> + +

{t("resultsTitle")}

diff --git a/app/[locale]/elo/page.tsx b/app/[locale]/elo/page.tsx index e069983..9ad6bef 100644 --- a/app/[locale]/elo/page.tsx +++ b/app/[locale]/elo/page.tsx @@ -15,6 +15,7 @@ import { TextField } from "@/components/form/TextField"; import { fetchTournamentResultsSchema } from "@/schemas"; import { trpc } from "@/utils/trpc"; +import { KFactor } from "./KFactor"; import { ManualEloForm } from "./ManualEloForm"; import { TournamentResults } from "./TournamentResults"; @@ -112,7 +113,7 @@ export default function Elo() {