From 318ef9afca5ffc1109f9a16a1ec54a382a2f62e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Fri, 7 Jun 2024 20:40:09 -0500 Subject: [PATCH] feat: better header --- src/app/tools/player-stats/[id]/page.tsx | 133 +++++------------------ src/app/tools/tankopedia/[id]/page.tsx | 2 +- src/components/BkniIndicator.tsx | 111 +++++++++++++++++++ src/components/PageWrapper.tsx | 4 +- 4 files changed, 139 insertions(+), 111 deletions(-) create mode 100644 src/components/BkniIndicator.tsx diff --git a/src/app/tools/player-stats/[id]/page.tsx b/src/app/tools/player-stats/[id]/page.tsx index a2e4f2d4b..75d838ebc 100644 --- a/src/app/tools/player-stats/[id]/page.tsx +++ b/src/app/tools/player-stats/[id]/page.tsx @@ -1,14 +1,9 @@ -import { TimerIcon } from '@radix-ui/react-icons'; -import { Button, Flex, Heading, Popover, Text } from '@radix-ui/themes'; +import { Box, Flex, Heading, Text } from '@radix-ui/themes'; +import { BkniIndicator } from '../../../../components/BkniIndicator'; import PageWrapper from '../../../../components/PageWrapper'; import { getAccountInfo } from '../../../../core/blitz/getAccountInfo'; import { getClanAccountInfo } from '../../../../core/blitz/getClanAccountInfo'; import { idToRegion } from '../../../../core/blitz/idToRegion'; -import getBkniPercentile, { - BKNI_COLORS, - BKNI_PERCENTILES, - BkniPercentile, -} from '../../../../core/statistics/getBkniPercentile'; import strings from '../../../../lang/en-US.json'; export default async function Page({ params }: { params: { id: string } }) { @@ -16,110 +11,34 @@ export default async function Page({ params }: { params: { id: string } }) { const region = idToRegion(id); const accountInfo = await getAccountInfo(region, id); const clanAccountInfo = await getClanAccountInfo(region, id, ['clan']); - const bkniRaw = Math.random() * 2 - 1; - const bkniFraction = (bkniRaw + 1) / 2; - const bkniMetric = Math.round(bkniFraction * 200); - const bkniPercentile = getBkniPercentile(bkniMetric); - const lastBkniPercentile = Math.max(0, bkniPercentile - 1) as BkniPercentile; - const bkniColor = BKNI_COLORS[bkniPercentile]; - const lastBkniColor = BKNI_COLORS[lastBkniPercentile]; + const bkni = Math.random() * 2 - 1; return ( - - - {accountInfo.nickname} - {clanAccountInfo?.clan && ( - [{clanAccountInfo.clan.tag}] - )} - + <> + + + + {accountInfo.nickname} - - - - - - - - - + + {clanAccountInfo?.clan && `[${clanAccountInfo.clan.tag}] • `} + {strings.common.regions.normal[region]} + + - - - - - - - {bkniMetric} - - - - - - - - - - - - BlitzKit Neutrality Index - - - A next generation performance metric - - - - {BKNI_PERCENTILES.map(({ percentile, min }, index) => ( - - ))} - - - + - - + + + + ); } diff --git a/src/app/tools/tankopedia/[id]/page.tsx b/src/app/tools/tankopedia/[id]/page.tsx index 52e2a425f..b7a35780c 100644 --- a/src/app/tools/tankopedia/[id]/page.tsx +++ b/src/app/tools/tankopedia/[id]/page.tsx @@ -69,7 +69,7 @@ export default function Page({ params }: { params: { id: string } }) { }, []); return ( - + {assigned && ( <> diff --git a/src/components/BkniIndicator.tsx b/src/components/BkniIndicator.tsx new file mode 100644 index 000000000..5c8d48da9 --- /dev/null +++ b/src/components/BkniIndicator.tsx @@ -0,0 +1,111 @@ +import { TimerIcon } from '@radix-ui/react-icons'; +import { Button, Flex, Heading, Popover, Text } from '@radix-ui/themes'; +import getBkniPercentile, { + BKNI_COLORS, + BKNI_PERCENTILES, + BkniPercentile, +} from '../core/statistics/getBkniPercentile'; +import strings from '../lang/en-US.json'; + +interface BkniIndicatorProps { + bkni: number; +} + +export function BkniIndicator({ bkni }: BkniIndicatorProps) { + const bkniFraction = (bkni + 1) / 2; + const bkniMetric = Math.round(bkniFraction * 200); + const bkniPercentile = getBkniPercentile(bkniMetric); + const lastBkniPercentile = Math.max(0, bkniPercentile - 1) as BkniPercentile; + const bkniColor = BKNI_COLORS[bkniPercentile]; + const lastBkniColor = BKNI_COLORS[lastBkniPercentile]; + + return ( + + + + + + + + + + + + + + + + + {bkniMetric} + + + + + + + + + + + + BlitzKit Neutrality Index + + + A next generation performance metric + + + + {BKNI_PERCENTILES.map(({ percentile, min }, index) => ( + + ))} + + + + + + ); +} diff --git a/src/components/PageWrapper.tsx b/src/components/PageWrapper.tsx index 680d0fd1e..ea3b1676f 100644 --- a/src/components/PageWrapper.tsx +++ b/src/components/PageWrapper.tsx @@ -4,7 +4,6 @@ import { ComponentProps } from 'react'; type PageWrapperProps = FlexProps & { color?: ComponentProps['accentColor']; size?: number | string; - noPadding?: boolean; noMaxWidth?: boolean; containerProps?: ComponentProps; noFlex1?: boolean; @@ -15,7 +14,6 @@ export default function PageWrapper({ color, size = 800, children, - noPadding = false, noMaxWidth = false, noFlex1 = false, containerProps, @@ -35,11 +33,11 @@ export default function PageWrapper({