Dashboard: Serie i Killstreak na wspolnym StatCard z wykresem obok liczby, etykieta w ostatnich 12 tygodniach
This commit is contained in:
@@ -54,7 +54,7 @@ function WeekBars({ values }: { values: number[] }) {
|
||||
const gap = 5;
|
||||
const bar = (w - gap * (n - 1)) / n;
|
||||
return (
|
||||
<div aria-hidden="true" className="mt-1.5 flex h-10 items-end">
|
||||
<div aria-hidden="true" className="flex h-14 items-end">
|
||||
<svg
|
||||
data-testid="week-bars"
|
||||
width={w}
|
||||
@@ -98,7 +98,7 @@ function StreakDots({ days }: { days: string[] }) {
|
||||
<div
|
||||
aria-hidden="true"
|
||||
data-testid="streak-dots"
|
||||
className="mt-1.5 flex h-10 flex-wrap content-center items-center gap-[3px]"
|
||||
className="flex h-14 flex-wrap content-center items-center gap-[3px]"
|
||||
>
|
||||
{cells.map((on, i) => (
|
||||
<span key={i} className={`h-1.5 w-1.5 rounded-full ${on ? 'bg-accent' : 'bg-dim/20'}`} />
|
||||
@@ -141,23 +141,29 @@ function ProgressRing({ percent }: { percent: number }) {
|
||||
);
|
||||
}
|
||||
|
||||
/* Karta statystyki: lbl + duża liczba (Space Grotesk) + opcjonalny dopisek kontekstowy. */
|
||||
/* Karta statystyki: lbl + duża liczba (Space Grotesk) + opcjonalny dopisek kontekstowy
|
||||
(+ opcjonalny wykres po prawej, wyśrodkowany na wysokości liczby). */
|
||||
function StatCard({
|
||||
label,
|
||||
value,
|
||||
sub,
|
||||
trailing,
|
||||
className = '',
|
||||
}: {
|
||||
label: string;
|
||||
value: ReactNode;
|
||||
sub?: ReactNode;
|
||||
trailing?: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<Card className={`mb-0 flex min-w-0 flex-col items-start gap-0.5 p-5 ${className}`.trim()}>
|
||||
<div className="text-[11px] font-bold uppercase tracking-[0.1em] text-dim">{label}</div>
|
||||
<div className="flex items-center gap-1.5 font-display text-[1.9rem] font-bold leading-tight tracking-[-0.02em] tabular-nums">
|
||||
{value}
|
||||
<div className="flex w-full min-w-0 items-center justify-between gap-x-6">
|
||||
<div className="flex min-w-0 items-center gap-1.5 font-display text-[1.9rem] font-bold leading-tight tracking-[-0.02em] tabular-nums">
|
||||
{value}
|
||||
</div>
|
||||
{trailing != null && <div className="flex-none">{trailing}</div>}
|
||||
</div>
|
||||
{sub != null && <div className="text-dim text-[0.8125rem]">{sub}</div>}
|
||||
</Card>
|
||||
@@ -418,30 +424,22 @@ export default function Dashboard() {
|
||||
{/* Historia — statystyki ponad wszystkimi planami (ukryta, gdy brak dorobku) */}
|
||||
{historyVisible && (
|
||||
<>
|
||||
{/* Jedna linia: Serie 3/8 + Killstreak 3/8 + Ukończone plany 2/8. */}
|
||||
{/* Jedna linia: Serie 3/8 + Killstreak 3/8 + Ukończone plany 2/8 — wspólny StatCard. */}
|
||||
<div className="mb-4 grid grid-cols-1 gap-4 sm:grid-cols-8">
|
||||
{/* Kafelek: łączna liczba serii + prawdziwy trend tygodniowy. */}
|
||||
<Card className="mb-0 flex min-w-0 flex-wrap items-end justify-between gap-x-8 gap-y-3 p-5 sm:col-span-3">
|
||||
<div className="min-w-0">
|
||||
<div className="text-[11px] font-bold uppercase tracking-[0.1em] text-dim">
|
||||
Serie
|
||||
</div>
|
||||
<div className="font-display text-[1.9rem] font-bold leading-tight tracking-[-0.02em] tabular-nums">
|
||||
{history.sets}
|
||||
</div>
|
||||
<div className="text-dim text-[0.8125rem]">serie w ostatnich tygodniach</div>
|
||||
</div>
|
||||
<WeekBars values={(data.weeklySets ?? []).map((w) => w.sets)} />
|
||||
</Card>
|
||||
<StatCard
|
||||
className="sm:col-span-3"
|
||||
label="Serie"
|
||||
value={history.sets}
|
||||
sub="w ostatnich 12 tygodniach"
|
||||
trailing={<WeekBars values={(data.weeklySets ?? []).map((w) => w.sets)} />}
|
||||
/>
|
||||
<StatCard
|
||||
className="sm:col-span-3"
|
||||
label="Killstreak"
|
||||
value={data.killstreak}
|
||||
sub={
|
||||
<>
|
||||
{`rekord: ${daysPlural(killstreakBest)}`}
|
||||
{data.killstreakDays != null && <StreakDots days={data.killstreakDays} />}
|
||||
</>
|
||||
sub={`rekord: ${daysPlural(killstreakBest)}`}
|
||||
trailing={
|
||||
data.killstreakDays != null ? <StreakDots days={data.killstreakDays} /> : null
|
||||
}
|
||||
/>
|
||||
{/* Plany + dorobek treningów (liczba na dole po prawej, jak w projekcie). */}
|
||||
|
||||
Reference in New Issue
Block a user