import { motion } from "motion/react";
import { Loader2, Mic, MicOff, Volume2 } from "lucide-react";
import type { VoiceState } from "../../../hooks/useVoiceSession";
interface VoiceMicButtonProps {
voiceState: VoiceState;
onToggle: () => void;
disabled?: boolean;
}
export default function VoiceMicButton({ voiceState, onToggle, disabled }: VoiceMicButtonProps) {
const isDisabled = disabled ?? false;
const stateConfig: Record<
VoiceState,
{ icon: React.ReactNode; className: string; title: string; pulse: boolean; scalePulse: boolean }
> = {
IDLE: {
icon: ,
className: "bg-neutral-100 text-neutral-400 hover:bg-brand-green/10 hover:text-brand-green",
title: "Start voice session",
pulse: false,
scalePulse: false,
},
CONNECTING: {
icon: ,
className: "bg-brand-green/10 text-brand-green/60",
title: "Connecting...",
pulse: false,
scalePulse: false,
},
LISTENING: {
icon: ,
className: "bg-brand-green text-white shadow-md shadow-brand-green/25",
title: "Listening — click to stop",
pulse: true,
scalePulse: false,
},
PROCESSING: {
icon: ,
className: "bg-brand-amber text-white",
title: "Processing...",
pulse: false,
scalePulse: false,
},
SPEAKING: {
icon: ,
className: "bg-brand-cyan text-white",
title: "Agent is speaking — click to stop",
pulse: false,
scalePulse: true,
},
ERROR: {
icon: ,
className: "bg-red-100 text-red-400 hover:bg-red-200",
title: "Connection failed — click to retry",
pulse: false,
scalePulse: false,
},
};
const cfg = stateConfig[voiceState];
return (
{cfg.pulse && (
)}
{cfg.icon}
);
}