import { Brain, Loader2, Mic } from 'lucide-react'; import type { MouseEvent, ReactElement } from 'react'; import { BUTTON_BACKGROUND_BY_STATE, MIC_BUTTON_STATES } from '../constants/constants'; import type { MicButtonState } from '../types/types'; type MicButtonViewProps = { state: MicButtonState; error: string | null; isSupported: boolean; className: string; onButtonClick: (event?: MouseEvent) => void; }; const getButtonIcon = (state: MicButtonState, isSupported: boolean): ReactElement => { if (!isSupported) { return ; } if (state === MIC_BUTTON_STATES.TRANSCRIBING) { return ; } if (state === MIC_BUTTON_STATES.PROCESSING) { return ; } if (state === MIC_BUTTON_STATES.RECORDING) { return ; } return ; }; export default function MicButtonView({ state, error, isSupported, className, onButtonClick, }: MicButtonViewProps) { const isDisabled = !isSupported || state === MIC_BUTTON_STATES.TRANSCRIBING || state === MIC_BUTTON_STATES.PROCESSING; const icon = getButtonIcon(state, isSupported); return (
{error && (
{error}
)} {state === MIC_BUTTON_STATES.RECORDING && (
)} {state === MIC_BUTTON_STATES.PROCESSING && (
)}
); }