audio-indicator.tsx 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. 'use client';
  2. import { motion } from 'motion/react';
  3. export type AudioIndicatorState = 'idle' | 'generating' | 'playing';
  4. interface AudioIndicatorProps {
  5. state: AudioIndicatorState;
  6. agentColor?: string;
  7. }
  8. const BAR_COUNT = 4;
  9. export function AudioIndicator({ state, agentColor = '#10b981' }: AudioIndicatorProps) {
  10. if (state === 'idle') return null;
  11. const color = state === 'generating' ? 'rgba(251, 191, 36, 0.7)' : agentColor;
  12. const cycleDuration = state === 'generating' ? 0.8 : 0.5;
  13. return (
  14. <span className="inline-flex items-end gap-[2px]" style={{ height: 12 }}>
  15. {Array.from({ length: BAR_COUNT }).map((_, i) => (
  16. <motion.span
  17. key={i}
  18. style={{
  19. width: 2,
  20. borderRadius: 1,
  21. backgroundColor: color,
  22. }}
  23. animate={{
  24. height: [4, 10 + (i % 2) * 2, 4],
  25. }}
  26. transition={{
  27. duration: cycleDuration,
  28. repeat: Infinity,
  29. ease: 'easeInOut',
  30. delay: i * (cycleDuration / BAR_COUNT),
  31. }}
  32. />
  33. ))}
  34. </span>
  35. );
  36. }