2025-07-12 19:59:22 +02:00
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
|
2025-07-13 00:30:19 +02:00
|
|
|
interface Milestone {
|
|
|
|
|
target: number;
|
|
|
|
|
description: string;
|
|
|
|
|
created_at: string;
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-12 19:59:22 +02:00
|
|
|
interface ProgressBarProps {
|
2025-07-13 00:30:19 +02:00
|
|
|
currentShares: number;
|
|
|
|
|
milestones: Milestone[];
|
2025-07-13 01:13:36 +02:00
|
|
|
selectedMilestoneIndex?: number;
|
2025-07-12 19:59:22 +02:00
|
|
|
className?: string;
|
|
|
|
|
onClick?: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function ProgressBar({
|
2025-07-13 00:30:19 +02:00
|
|
|
currentShares,
|
|
|
|
|
milestones,
|
2025-07-13 01:13:36 +02:00
|
|
|
selectedMilestoneIndex = 0,
|
2025-07-12 19:59:22 +02:00
|
|
|
className,
|
|
|
|
|
onClick
|
|
|
|
|
}: ProgressBarProps) {
|
2025-07-13 01:13:36 +02:00
|
|
|
// Get the selected milestone for progress calculation
|
|
|
|
|
const selectedMilestone = milestones.length > 0 && selectedMilestoneIndex < milestones.length
|
|
|
|
|
? milestones[selectedMilestoneIndex]
|
|
|
|
|
: null;
|
2025-07-13 00:30:19 +02:00
|
|
|
|
|
|
|
|
// Calculate progress percentage
|
2025-07-13 01:13:36 +02:00
|
|
|
const progressPercentage = selectedMilestone
|
|
|
|
|
? Math.min((currentShares / selectedMilestone.target) * 100, 100)
|
2025-07-13 00:30:19 +02:00
|
|
|
: 0;
|
2025-07-12 19:59:22 +02:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className={cn(
|
2025-07-13 00:30:19 +02:00
|
|
|
"bg-black cursor-pointer",
|
2025-07-12 19:59:22 +02:00
|
|
|
"transition-all duration-300",
|
2025-07-13 00:30:19 +02:00
|
|
|
"p-8",
|
2025-07-12 19:59:22 +02:00
|
|
|
className
|
|
|
|
|
)}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
>
|
2025-07-13 00:30:19 +02:00
|
|
|
{/* Progress Bar Container */}
|
|
|
|
|
<div className="w-full">
|
|
|
|
|
{/* Old-school progress bar with overlaid text */}
|
|
|
|
|
<div className="w-full border-4 border-red-500 p-2 bg-black relative overflow-hidden">
|
|
|
|
|
{/* Inner container */}
|
|
|
|
|
<div className="relative h-8">
|
|
|
|
|
{/* Progress fill */}
|
|
|
|
|
<div
|
|
|
|
|
className="absolute top-0 left-0 h-full bg-red-500 transition-all duration-500 ease-out"
|
|
|
|
|
style={{ width: `${progressPercentage}%` }}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Text overlay */}
|
2025-07-13 01:13:36 +02:00
|
|
|
{selectedMilestone && (
|
2025-07-13 00:30:19 +02:00
|
|
|
<div className="relative h-full flex items-center justify-center">
|
|
|
|
|
{/* Base text (red on black background) */}
|
|
|
|
|
<div className="text-red-500 font-mono text-sm font-bold mix-blend-difference relative z-10">
|
|
|
|
|
{progressPercentage.toFixed(1)}%
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-07-12 19:59:22 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|