Files
knur-app/components/volume-chart.tsx
Dominik Klarkowski 4b3373869b init
2026-06-22 15:19:38 +02:00

47 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
import { useEffect, useState } from "react";
import { Bar, BarChart, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
type VolumeChartProps = {
data: { label: string; volumeKg: number }[];
};
export function VolumeChart({ data }: VolumeChartProps) {
const [mounted, setMounted] = useState(false);
useEffect(() => setMounted(true), []);
if (!mounted) {
return (
<div className="w-full rounded-2xl border border-white/10 bg-surface/55 shadow-lg shadow-black/10 backdrop-blur-md p-4">
<div className="mb-2 h-4 w-56 animate-pulse rounded bg-white/10" />
<div className="h-[180px] animate-pulse rounded bg-white/5" />
</div>
);
}
return (
<div className="w-full rounded-2xl border border-white/10 bg-surface/55 shadow-lg shadow-black/10 backdrop-blur-md p-4">
<div className="mb-2 text-sm text-fg/60">Wolumen treningowy (ciężar × powtórzenia)</div>
<ResponsiveContainer width="100%" height={180}>
<BarChart data={data} margin={{ top: 8, right: 8, left: 0, bottom: 0 }}>
<XAxis dataKey="label" stroke="var(--color-fg)" opacity={0.5} fontSize={12} />
<YAxis stroke="var(--color-fg)" opacity={0.5} fontSize={12} width={48} />
<Tooltip
cursor={{ fill: "var(--color-bg)" }}
contentStyle={{
background: "color-mix(in oklab, var(--color-surface) 92%, transparent)",
border: "1px solid rgba(255,255,255,0.12)",
borderRadius: 12,
fontSize: 12,
color: "var(--color-fg)",
}}
formatter={(value) => [`${Math.round(Number(value)).toLocaleString("pl-PL")} kg`, "Wolumen"]}
/>
<Bar dataKey="volumeKg" fill="var(--color-accent)" radius={[4, 4, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</div>
);
}