'use client'; import { forwardRef, HTMLAttributes } from 'react'; export interface ProgressDotItem { id: string; label?: string; href?: string; } export interface ProgressDotsProps extends HTMLAttributes { items: ProgressDotItem[]; activeId?: string; variant?: 'default' | 'gold' | 'minimal'; direction?: 'vertical' | 'horizontal'; showConnector?: boolean; onDotClick?: (id: string) => void; } const variantColors: Record = { default: { border: 'border-gray-600', active: 'border-red-500 shadow-[0_0_10px_rgba(255,0,64,0.5)]', shadow: 'bg-red-500' }, gold: { border: 'border-amber-700', active: 'border-amber-500 shadow-[0_0_10px_rgba(201,162,39,0.5)]', shadow: 'bg-amber-500' }, minimal: { border: 'border-gray-600', active: 'border-red-500', shadow: 'bg-red-500' }, }; export const ProgressDots = forwardRef( ({ items, activeId, variant = 'default', direction = 'vertical', showConnector = false, onDotClick, className, ...props }, ref) => { const colors = variantColors[variant]; const containerClasses = ` fixed z-50 flex gap-6 ${direction === 'vertical' ? 'right-8 top-1/2 -translate-y-1/2 flex-col' : 'bottom-8 left-1/2 -translate-x-1/2 flex-row' } ${className || ''} `; const handleClick = (id: string, href?: string) => { if (onDotClick) onDotClick(id); if (href) { const el = document.querySelector(href); el?.scrollIntoView({ behavior: 'smooth' }); } }; return (
{items.map((item) => { const isActive = activeId === item.id; const dotSize = variant === 'minimal' ? 'w-2 h-2 border' : 'w-3 h-3 border-2'; return ( ); })}
); } ); ProgressDots.displayName = 'ProgressDots'; export default ProgressDots;