"use client"; import * as React from "react"; import { cn } from "./lib/utils"; export interface HealthBarProps extends React.HTMLAttributes { value: number; max?: number; label?: string; segments?: number; } /** Health bar: segmented vitality meter with low-health pulse and motion-reduce fallback. */ export function HealthBar({ value, max = 100, label = "HP", segments = 10, className, ...props }: HealthBarProps) { const pct = Math.max(0, Math.min(100, (value / Math.max(1, max)) * 100)); const filled = Math.round((pct / 100) * segments); const low = pct <= 25; return (
{label} {value}/{max}
{Array.from({ length: segments }).map((_, i) => (
); }