File size: 1,102 Bytes
f56a29b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


import { motion } from 'motion/react';

export type AudioIndicatorState = 'idle' | 'generating' | 'playing';

interface AudioIndicatorProps {
  state: AudioIndicatorState;
  agentColor?: string;
}

const BAR_COUNT = 4;

export function AudioIndicator({ state, agentColor = '#10b981' }: AudioIndicatorProps) {
  if (state === 'idle') return null;

  const color = state === 'generating' ? 'rgba(251, 191, 36, 0.7)' : agentColor;
  const cycleDuration = state === 'generating' ? 0.8 : 0.5;

  return (
    <span className="inline-flex items-end gap-[2px]" style={{ height: 12 }}>
      {Array.from({ length: BAR_COUNT }).map((_, i) => (
        <motion.span
          key={i}
          style={{
            width: 2,
            borderRadius: 1,
            backgroundColor: color,
          }}
          animate={{
            height: [4, 10 + (i % 2) * 2, 4],
          }}
          transition={{
            duration: cycleDuration,
            repeat: Infinity,
            ease: 'easeInOut',
            delay: i * (cycleDuration / BAR_COUNT),
          }}
        />
      ))}
    </span>
  );
}