/** * Trend Indicator Component * Shows trend direction with visual indicators */ import { TrendDirection } from '../../lib/analytics/types'; interface TrendIndicatorProps { direction: TrendDirection; value?: number; showLabel?: boolean; size?: 'sm' | 'md' | 'lg'; } const sizeClasses = { sm: 'w-3 h-3', md: 'w-4 h-4', lg: 'w-5 h-5', }; const textSizeClasses = { sm: 'text-xs', md: 'text-sm', lg: 'text-base', }; export default function TrendIndicator({ direction, value, showLabel = false, size = 'md', }: TrendIndicatorProps) { const iconSize = sizeClasses[size]; const textSize = textSizeClasses[size]; const getColor = () => { switch (direction) { case 'up': return 'text-green-500'; case 'down': return 'text-red-500'; default: return 'text-gray-400'; } }; const getBgColor = () => { switch (direction) { case 'up': return 'bg-green-100'; case 'down': return 'bg-red-100'; default: return 'bg-gray-100'; } }; const getIcon = () => { switch (direction) { case 'up': return ( ); case 'down': return ( ); default: return ( ); } }; const getLabel = () => { switch (direction) { case 'up': return 'Increasing'; case 'down': return 'Decreasing'; default: return 'Stable'; } }; return (
{getIcon()} {value !== undefined && ( {value > 0 ? '+' : ''}{value.toFixed(1)}% )} {showLabel && ( {getLabel()} )}
); }