import { ReactNode } from 'react'; import { cn } from '@/lib/utils'; import { formatDate } from '@/utils/date'; export interface TimelineItem { id: string; title: string; description?: string; date: Date | string; icon?: ReactNode; } export interface TimelineProps { items: TimelineItem[]; orientation?: 'vertical' | 'horizontal'; className?: string; } /** * Composant Timeline pour afficher des événements chronologiques. */ export function Timeline({ items, orientation = 'vertical', className, }: TimelineProps) { if (items.length === 0) { return (
Aucun événement à afficher
); } if (orientation === 'horizontal') { return (
{items.map((item, index) => (
{/* Ligne horizontale */} {index < items.length - 1 && (
)} {/* Icône */}
{item.icon ? (
{item.icon}
) : (
)}
{/* Contenu */}
{item.title}
{item.description && (
{item.description}
)}
{formatDate(item.date, 'short')}
))}
); } // Orientation verticale (par défaut) return (
{items.map((item, index) => (
{/* Ligne verticale */} {index < items.length - 1 && (
)} {/* Icône */}
{item.icon ? (
{item.icon}
) : (
)}
{/* Contenu */}
{item.title}
{item.description && (
{item.description}
)}
{formatDate(item.date, 'short')}
))}
); }