diff --git a/src/client/components/donut.tsx b/src/client/components/donut.tsx index 67e86f1..4398ee7 100644 --- a/src/client/components/donut.tsx +++ b/src/client/components/donut.tsx @@ -26,6 +26,10 @@ export interface DonutProps { centerSub?: ReactNS.ReactNode /** Outer size in px (default 118). */ size?: number + /** The hovered slice key — the legend row ↔ segment hover link. */ + hoverKey?: string | null + /** Hover relay; absent renders the ring inert. */ + onHoverKey?: (key: string | null) => void } export function makeDonut(kit: ViewKit): (props: DonutProps) => ReactNS.ReactElement { @@ -50,14 +54,23 @@ export function makeDonut(kit: ViewKit): (props: DonutProps) => ReactNS.ReactEle acc += pct } } + // The ring dims only for a hover that lands on a painted arc — a legend + // row without a segment (a zero slice) leaves the ring at rest. + const hovering = props.hoverKey !== null && props.hoverKey !== undefined + && arcs.some(a => a.key === props.hoverKey) return ( -