"use client"; // Adapted from Kokonut UI (@kokonutui), MIT. See THIRD_PARTY_NOTICES.md. import { type ComponentProps, type CSSProperties } from "react"; export interface ActivityRing { label: string; value: number; max?: number; color?: string; } export interface ActivityRingsProps extends ComponentProps<"div"> { rings: readonly ActivityRing[]; } export function ActivityRings({ rings, className = "", ...props }: ActivityRingsProps) { const values = rings.map((ring) => { const requestedMax = ring.max ?? 100; const max = Number.isFinite(requestedMax) && requestedMax > 0 ? requestedMax : 100; const value = Number.isFinite(ring.value) ? Math.max(0, Math.min(max, ring.value)) : 0; return { ...ring, max, value }; }); const size = 40 + values.length * 24; return (
{values.map((ring, i) => (
{ring.label} {ring.value} / {ring.max}
))}
); }