import React from 'react'; import type { DeployState } from '../../types/deployer'; import './DeployProgress.css'; interface DeployProgressProps { state: DeployState; message: string; completed: number; total: number; percent: number; } const STATE_GRADIENT: Record = { compiling: 'linear-gradient(90deg, #3b82f6, #60a5fa)', // blue transferring: 'linear-gradient(90deg, #f59e0b, #fbbf24)', // amber/yellow flashing: 'linear-gradient(90deg, #22c55e, #4ade80)', // green serial_bridge:'linear-gradient(90deg, #8b5cf6, #a78bfa)', // purple success: 'linear-gradient(90deg, #22c55e, #4ade80)', // green }; const STATE_SPINNER_COLOR: Record = { compiling: '#3b82f6', transferring: '#f59e0b', flashing: '#22c55e', serial_bridge:'#8b5cf6', }; const DEFAULT_GRADIENT = 'linear-gradient(90deg, #3b82f6, #22c55e)'; const DEFAULT_SPINNER_COLOR = '#3b82f6'; export const DeployProgress: React.FC = ({ state, message, completed, total, percent, }) => { const showBar = total > 0 && (state === 'transferring' || state === 'flashing' || state === 'serial_bridge'); const showSpinner = state === 'compiling' || state === 'pairing' || (state === 'transferring' && total === 0); const barGradient = STATE_GRADIENT[state] ?? DEFAULT_GRADIENT; const spinnerColor = STATE_SPINNER_COLOR[state] ?? DEFAULT_SPINNER_COLOR; return (
{message} {showBar && ( Chunk {completed}/{total} ({percent}%) )}
{showBar && (
)} {showSpinner && (
)}
); };