Files
temetro/frontend/components/charts/animation.ts
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

37 lines
1.0 KiB
TypeScript

import type { Transition } from "motion/react";
/** Default clip-reveal easing for cartesian charts. */
export const DEFAULT_ANIMATION_EASING = "cubic-bezier(0.85, 0, 0.15, 1)";
export const DEFAULT_ANIMATION_DURATION_MS = 1100;
/** Default enter transition — matches the original line chart reveal. */
export const DEFAULT_CHART_ENTER_TRANSITION: Transition = {
type: "tween",
duration: DEFAULT_ANIMATION_DURATION_MS / 1000,
ease: [0.85, 0, 0.15, 1],
};
/**
* Clip-path width reveal must use tween — spring does not reliably animate SVG width.
*/
export function clipRevealTransition(enterTransition?: Transition): Transition {
if (enterTransition?.type === "tween") {
return {
...enterTransition,
ease: enterTransition.ease ?? DEFAULT_CHART_ENTER_TRANSITION.ease,
};
}
const duration =
typeof enterTransition?.duration === "number"
? enterTransition.duration
: DEFAULT_ANIMATION_DURATION_MS / 1000;
return {
type: "tween",
duration,
ease: DEFAULT_CHART_ENTER_TRANSITION.ease,
};
}