import clsx from 'clsx' interface FuelGaugeProps { value: number // 0-100 maxValue?: number label?: string size?: 'sm' | 'md' | 'lg' showPercentage?: boolean className?: string } export default function FuelGauge({ value, maxValue = 100, label = 'Combustible', size = 'md', showPercentage = true, className, }: FuelGaugeProps) { const percentage = Math.min(100, Math.max(0, (value / maxValue) * 100)) // Color based on level const getColor = () => { if (percentage <= 20) return { bg: 'bg-error-500', text: 'text-error-400' } if (percentage <= 40) return { bg: 'bg-warning-500', text: 'text-warning-400' } return { bg: 'bg-success-500', text: 'text-success-400' } } const colors = getColor() const sizeStyles = { sm: { height: 'h-2', text: 'text-xs', icon: 'w-4 h-4' }, md: { height: 'h-3', text: 'text-sm', icon: 'w-5 h-5' }, lg: { height: 'h-4', text: 'text-base', icon: 'w-6 h-6' }, } const styles = sizeStyles[size] return (
{/* Header */}
{label}
{showPercentage && ( {percentage.toFixed(0)}% )}
{/* Gauge bar */}
{/* Markers */}
E 1/4 1/2 3/4 F
) } // Circular gauge variant interface CircularGaugeProps { value: number maxValue?: number label?: string size?: number strokeWidth?: number className?: string } export function CircularGauge({ value, maxValue = 100, label, size = 120, strokeWidth = 8, className, }: CircularGaugeProps) { const percentage = Math.min(100, Math.max(0, (value / maxValue) * 100)) const radius = (size - strokeWidth) / 2 const circumference = 2 * Math.PI * radius const strokeDashoffset = circumference - (percentage / 100) * circumference // Color based on level const getColor = () => { if (percentage <= 20) return '#ef4444' if (percentage <= 40) return '#eab308' return '#22c55e' } return (
{/* Background circle */} {/* Progress circle */} {/* Center content */}

{percentage.toFixed(0)}%

{label &&

{label}

}
) }