From 7eb13c199b53173f5b48f97da9c42a05103bdde7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com>
Date: Fri, 12 Jul 2024 13:01:10 -0500
Subject: [PATCH] feat: sticky headers
---
.vscode/settings.json | 1 +
src/app/tools/player-stats/[id]/page.tsx | 2 +-
.../tank-performance/components/Header.tsx | 8 ++---
.../tank-performance/components/Table.tsx | 2 +-
.../tank-performance/components/Total.tsx | 7 +++-
src/app/tools/tank-performance/page.tsx | 3 +-
src/components/StickyColumnHeaderCell.tsx | 20 +++++++++++
src/components/StickyRowHeaderCell.tsx | 1 -
src/components/TankRowHeaderCell.tsx | 16 +++------
src/core/statistics/getBkniPercentile.ts | 34 ++++++-------------
10 files changed, 48 insertions(+), 46 deletions(-)
create mode 100644 src/components/StickyColumnHeaderCell.tsx
diff --git a/.vscode/settings.json b/.vscode/settings.json
index d9be76451..1c2e5ac5f 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -118,6 +118,7 @@
"POSITIVEX",
"POSITIVEY",
"POSITIVEZ",
+ "precompute",
"Promisable",
"protobuf",
"protos",
diff --git a/src/app/tools/player-stats/[id]/page.tsx b/src/app/tools/player-stats/[id]/page.tsx
index 66bdcba55..544435af3 100644
--- a/src/app/tools/player-stats/[id]/page.tsx
+++ b/src/app/tools/player-stats/[id]/page.tsx
@@ -213,7 +213,7 @@ export default function Page({ params }: { params: { id: string } }) {
{strings.common.bkni_percentile[percentile]}
- {min} - {BKNI_PERCENTILES[index + 1]?.min ?? 200}
+ {min}% - {BKNI_PERCENTILES[index + 1]?.min ?? 100}%
diff --git a/src/app/tools/tank-performance/components/Header.tsx b/src/app/tools/tank-performance/components/Header.tsx
index fd2aade88..d4cf02e22 100644
--- a/src/app/tools/tank-performance/components/Header.tsx
+++ b/src/app/tools/tank-performance/components/Header.tsx
@@ -6,6 +6,7 @@ import {
CaretUpIcon,
} from '@radix-ui/react-icons';
import { Flex, IconButton, Table } from '@radix-ui/themes';
+import { StickyColumnHeaderCell } from '../../../../components/StickyColumnHeaderCell';
import * as TankPerformanceSort from '../../../../stores/tankPerformanceSort';
import {
tankPerformanceSortTypeNames,
@@ -19,17 +20,16 @@ export function Header() {
return (
- Tank
+ Tank
{tankPerformanceSortTypeNamesArray.map((type) => {
const isSelected = sort.type === type;
return (
-
{tankPerformanceSortTypeNames[type]}
@@ -56,7 +56,7 @@ export function Header() {
)}
-
+
);
})}
diff --git a/src/app/tools/tank-performance/components/Table.tsx b/src/app/tools/tank-performance/components/Table.tsx
index ef356765f..f0b028119 100644
--- a/src/app/tools/tank-performance/components/Table.tsx
+++ b/src/app/tools/tank-performance/components/Table.tsx
@@ -13,7 +13,7 @@ export function TankTable() {
}>
diff --git a/src/app/tools/tank-performance/components/Total.tsx b/src/app/tools/tank-performance/components/Total.tsx
index b83187e36..4a2656763 100644
--- a/src/app/tools/tank-performance/components/Total.tsx
+++ b/src/app/tools/tank-performance/components/Total.tsx
@@ -43,7 +43,12 @@ export const Total = memo(
return (
- Total
+
+ Total
+
{(winrate * 100).toFixed(1)}%
{formatCompact(ratio * players)}
{formatCompact(ratio * battles)}
diff --git a/src/app/tools/tank-performance/page.tsx b/src/app/tools/tank-performance/page.tsx
index 4bb880d81..9a119a1f5 100644
--- a/src/app/tools/tank-performance/page.tsx
+++ b/src/app/tools/tank-performance/page.tsx
@@ -2,13 +2,12 @@ import PageWrapper from '../../../components/PageWrapper';
import { FilterControl } from '../tankopedia/components/FilterControl';
import { Info } from './components/Info';
import { TankTable } from './components/Table';
-import { TierBreakdown } from './components/TierBreakdown';
export default function Page() {
return (
-
+ {/* */}
diff --git a/src/components/StickyColumnHeaderCell.tsx b/src/components/StickyColumnHeaderCell.tsx
new file mode 100644
index 000000000..a0a4dc8ce
--- /dev/null
+++ b/src/components/StickyColumnHeaderCell.tsx
@@ -0,0 +1,20 @@
+import { Table } from '@radix-ui/themes';
+import { ColumnHeaderCellProps } from '@radix-ui/themes/dist/cjs/components/table';
+
+export function StickyColumnHeaderCell({
+ style,
+ ...props
+}: ColumnHeaderCellProps) {
+ return (
+
+ );
+}
diff --git a/src/components/StickyRowHeaderCell.tsx b/src/components/StickyRowHeaderCell.tsx
index 08aefc48b..2c2478dcb 100644
--- a/src/components/StickyRowHeaderCell.tsx
+++ b/src/components/StickyRowHeaderCell.tsx
@@ -8,7 +8,6 @@ export function StickyRowHeaderCell({ style, ...props }: RowHeaderCellProps) {
position: 'sticky',
left: 0,
backgroundColor: 'var(--color-panel)',
- boxShadow: 'var(--shadow-6)',
...style,
}}
{...props}
diff --git a/src/components/TankRowHeaderCell.tsx b/src/components/TankRowHeaderCell.tsx
index 5d0908f15..7361588c8 100644
--- a/src/components/TankRowHeaderCell.tsx
+++ b/src/components/TankRowHeaderCell.tsx
@@ -14,14 +14,8 @@ export function TankRowHeaderCell({ tank }: TankRowHeaderCellProps) {
return (
{tank.name}
diff --git a/src/core/statistics/getBkniPercentile.ts b/src/core/statistics/getBkniPercentile.ts
index 31584b723..57c129059 100644
--- a/src/core/statistics/getBkniPercentile.ts
+++ b/src/core/statistics/getBkniPercentile.ts
@@ -1,17 +1,3 @@
-/**
- * (10) 0 - 10: super malum
- * (10) 10 - 20: malum
- * (20) 20 - 40: very bad
- * (20) 40 - 60: bad
- * (20) 60 - 80: below average
- * (40) 80 - 120: average
- * (20) 120 - 140: above average
- * (20) 140 - 160: good
- * (20) 160 - 180: very good
- * (10) 180 - 190: unicum
- * (10) 190 - 200: super unicum
- */
-
export enum BkniPercentile {
SuperMalum,
Malum,
@@ -28,16 +14,16 @@ export enum BkniPercentile {
export const BKNI_PERCENTILES = [
{ min: 0, percentile: BkniPercentile.SuperMalum },
- { min: 10, percentile: BkniPercentile.Malum },
- { min: 20, percentile: BkniPercentile.VeryBad },
- { min: 40, percentile: BkniPercentile.Bad },
- { min: 60, percentile: BkniPercentile.BelowAverage },
- { min: 80, percentile: BkniPercentile.Average },
- { min: 120, percentile: BkniPercentile.AboveAverage },
- { min: 140, percentile: BkniPercentile.Good },
- { min: 160, percentile: BkniPercentile.VeryGood },
- { min: 180, percentile: BkniPercentile.Unicum },
- { min: 190, percentile: BkniPercentile.SuperUnicum },
+ { min: 1, percentile: BkniPercentile.Malum },
+ { min: 10, percentile: BkniPercentile.VeryBad },
+ { min: 20, percentile: BkniPercentile.Bad },
+ { min: 30, percentile: BkniPercentile.BelowAverage },
+ { min: 40, percentile: BkniPercentile.Average },
+ { min: 60, percentile: BkniPercentile.AboveAverage },
+ { min: 70, percentile: BkniPercentile.Good },
+ { min: 80, percentile: BkniPercentile.VeryGood },
+ { min: 90, percentile: BkniPercentile.Unicum },
+ { min: 99, percentile: BkniPercentile.SuperUnicum },
];
export const BKNI_COLORS = {