diff --git a/frontend/src/pages/Stats.tsx b/frontend/src/pages/Stats.tsx index 1178d93..e78c736 100644 --- a/frontend/src/pages/Stats.tsx +++ b/frontend/src/pages/Stats.tsx @@ -96,6 +96,13 @@ function PokemonList({ ) } +function hexLuminance(hex: string): number { + const r = parseInt(hex.slice(1, 3), 16) + const g = parseInt(hex.slice(3, 5), 16) + const b = parseInt(hex.slice(5, 7), 16) + return (0.299 * r + 0.587 * g + 0.114 * b) / 255 +} + function HorizontalBar({ label, value, @@ -110,12 +117,10 @@ function HorizontalBar({ colorHex?: string }) { const width = max > 0 ? (value / max) * 100 : 0 + const isLight = colorHex ? hexLuminance(colorHex) > 0.55 : false return (
- - {label} - -
+
+ + {label} +
{value}