diff --git a/resources/js/components/Display/LedDisplay.tsx b/resources/js/components/Display/LedDisplay.tsx index 822242f..77d24a8 100644 --- a/resources/js/components/Display/LedDisplay.tsx +++ b/resources/js/components/Display/LedDisplay.tsx @@ -8,97 +8,53 @@ interface LedDisplayProps { onClick?: () => void; } -export default function LedDisplay({ - value, - className, - animate = true, +export default function LedDisplay({ + value, + className, onClick }: LedDisplayProps) { const [displayValue, setDisplayValue] = useState(0); // Animate number changes useEffect(() => { - if (!animate) { - setDisplayValue(value); - return; - } + setDisplayValue(value); + return; + }, [value]); - const duration = 1000; // 1 second animation - const steps = 60; // 60fps - const stepValue = (value - displayValue) / steps; - - if (Math.abs(stepValue) < 0.01) { - setDisplayValue(value); - return; - } - - const timer = setInterval(() => { - setDisplayValue(prev => { - const next = prev + stepValue; - if (Math.abs(next - value) < Math.abs(stepValue)) { - clearInterval(timer); - return value; - } - return next; - }); - }, duration / steps); - - return () => clearInterval(timer); - }, [value, displayValue, animate]); - - // Format number appropriately for shares + // Format number with zero-padding for consistent width const formatValue = (value: number) => { - // If it's a whole number, show it as integer - if (value % 1 === 0) { - return value.toString(); - } - // Otherwise show up to 6 decimal places, removing trailing zeros - return value.toFixed(6).replace(/\.?0+$/, ''); + // Always pad to 5 digits for consistent display width + const integerPart = Math.floor(value); + return integerPart.toString().padStart(5, '0'); }; - + const formattedValue = formatValue(displayValue); return ( -