Files
temetro/frontend/components/charts/series-highlight-layer.tsx
T
Khalid Abdi 321a6298a4 frontend: pharmacy inventory, lab add-result & analysis charts
- Pharmacy: the sidebar entry now expands into Pharmacy + a new Inventory page
  (searchable medication stock with derived in-stock/low/out availability,
  backed by /api/inventory). Fix the dispensing-queue "Expiring" badge so it
  only flags courses ending within the next 7 days, not ones already elapsed.
- Lab "Add analysis result": the patient picker no longer lists patients until
  you type and supports arrow-key + Enter selection; the test field offers a
  catalog of common analyses with an Advanced option (custom analysis + ref
  range); submitted results now show immediately in a Recent results feed.
- Analysis: add a Live panel (real-time line chart) and replace the flat trend
  sparklines with bklit-ui area + bar charts (installed from the @bklit shadcn
  registry; chart CSS variables wired into the theme for light and dark).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-12 19:22:07 +03:00

50 lines
1.4 KiB
TypeScript

"use client";
import type { RefObject } from "react";
import { useChartStable } from "./chart-context";
import { HighlightSegment } from "./highlight-segment";
import { useHighlightSegment } from "./use-highlight-segment";
interface SeriesHighlightLayerProps {
/** Caller already gated `showHighlight && showLine`; this just routes through. */
enabled: boolean;
height: number;
pathRef: RefObject<SVGPathElement | null>;
stroke: string;
strokeWidth: number;
}
/**
* Self-contained hover-highlight band over a series stroke.
*
* Owns the `useHighlightSegment` subscription (which reads both stable + hover
* context) so the parent <Area> / <Line> can stay on the stable slice. This
* component still re-renders on hover — that's the price of driving the
* highlight band — but it's a tiny leaf so the cost is bounded to itself.
*/
export function SeriesHighlightLayer({
enabled,
height,
pathRef,
stroke,
strokeWidth,
}: SeriesHighlightLayerProps) {
const { isLoaded } = useChartStable();
const { xSpring, widthSpring, isActive } = useHighlightSegment({ enabled });
return (
<HighlightSegment
height={height}
pathRef={pathRef}
stroke={stroke}
strokeWidth={strokeWidth}
visible={enabled && isActive && isLoaded}
width={widthSpring}
x={xSpring}
/>
);
}
SeriesHighlightLayer.displayName = "SeriesHighlightLayer";
export default SeriesHighlightLayer;