diff --git a/src/components/online/CoinsPill.tsx b/src/components/online/CoinsPill.tsx index b79f028..3a24bc9 100644 --- a/src/components/online/CoinsPill.tsx +++ b/src/components/online/CoinsPill.tsx @@ -6,6 +6,13 @@ import { useUIStore } from "@/lib/ui-store"; import { useI18n } from "@/lib/i18n"; import { cn } from "@/lib/cn"; +/** Compact balance so big numbers don't overflow tight headers (104,240 → 104K). */ +function fmtCoins(n: number): string { + if (n < 10_000) return n.toLocaleString(); + if (n < 1_000_000) return `${(n / 1000).toFixed(n < 100_000 ? 1 : 0)}K`.replace(".0K", "K"); + return `${(n / 1_000_000).toFixed(1)}M`.replace(".0M", "M"); +} + /** * The coin balance, as a button that opens the buy-coins store. Use it anywhere * coins are shown so tapping the balance always leads to topping up. @@ -17,15 +24,15 @@ export function CoinsPill({ className }: { className?: string }) { return ( -
+