import { For, Show, type Component } from "solid-js"; import { cn } from "@/lib/cn"; import { useT } from "@/stores/preferences-context"; export type ProgressRingSegment = { id: string; label: string; value: number; colorClass: string; }; export type ChartProgressRingProps = { title?: string; subtitle?: string; valueText?: string; subtext?: string; segments: ProgressRingSegment[]; total?: number; class?: string; }; export const ChartProgressRing: Component = (props) => { const t = useT(); const calculatedTotal = () => props.total ?? props.segments.reduce((acc, s) => acc + s.value, 0); return (

{props.title}

{props.subtitle}

0} fallback={

{t("dashboard.chartEmpty")}

{t("dashboard.chartEmptyHint")}

} >
{/* Total Stat Highlight */}
{props.valueText ?? calculatedTotal()} {props.subtext}
{/* Multi-Segmented Progress Gauge Bar */}
{(segment) => { const pct = () => (calculatedTotal() > 0 ? (segment.value / calculatedTotal()) * 100 : 0); return ( 0}>
); }}
{/* Legend Grid */}
{(segment) => (
{segment.label}
{segment.value}
)}
); };