import { useState } from "react"; import type { DayCount } from "../lib/types"; import { weekdayLabel } from "../lib/format"; interface Props { data: DayCount[]; height?: number; } // ponytail: no grow-in animation — this renders on every dashboard page view, // and motion seen tens of times a day just reads as lag. export function BarChart({ data, height = 84 }: Props) { const [hover, setHover] = useState(null); const max = Math.max(1, ...data.map((d) => d.count)); return (
{data.map((d, i) => { const ratio = d.count / max; const active = hover === i; return (
setHover(i)} onMouseLeave={() => setHover(null)} > {active && (
{d.count} {d.count === 1 ? "click" : "clicks"}
)}
{weekdayLabel(d.date)}
); })}
); }