"use client"; import { HTMLAttributes } from "react"; interface ProgressBarProps extends HTMLAttributes { value: number; max: number; variant?: "hp" | "xp" | "default"; showLabel?: boolean; label?: string; } const getGradientStyle = ( variant: "hp" | "xp" | "default", percentage: number ) => { if (variant === "hp") { if (percentage > 60) { return { background: `linear-gradient(to right, var(--success), color-mix(in srgb, var(--success) 90%, transparent))`, }; } else if (percentage > 30) { return { background: `linear-gradient(to right, var(--yellow), color-mix(in srgb, var(--accent) 90%, transparent))`, }; } else { return { background: `linear-gradient(to right, var(--destructive), color-mix(in srgb, var(--destructive) 90%, transparent))`, }; } } else { return { background: `linear-gradient(to right, color-mix(in srgb, var(--accent-color) 80%, transparent), color-mix(in srgb, var(--accent-color) 70%, transparent), color-mix(in srgb, var(--accent-color) 80%, transparent) )`, }; } }; export default function ProgressBar({ value, max, variant = "default", showLabel = false, label, className = "", ...props }: ProgressBarProps) { const percentage = Math.min(100, Math.max(0, (value / max) * 100)); return (
{showLabel && (
{label || variant.toUpperCase()} {value} / {max}
)}
{variant === "hp" && percentage < 30 && (
)}
); }