File size: 1,974 Bytes
1a9c884
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
48
49
50
51
import { PROMPTS, GLASS_EFFECTS } from "../constants";
import GlassContainer from "./GlassContainer";

interface LiveCaptionProps {
  caption: string;
  isRunning?: boolean;
  error?: string | null;
}

export default function LiveCaption({ caption, isRunning, error }: LiveCaptionProps) {
  const content = error || caption;

  const { color, label } = error
    ? { color: "bg-red-500", label: "ERROR" }
    : isRunning
      ? { color: "bg-green-500 animate-pulse", label: "RUNNING" }
      : { color: "bg-yellow-500 animate-pulse", label: "STOPPED" };

  return (
    <GlassContainer

      bgColor={error ? GLASS_EFFECTS.COLORS.ERROR_BG : GLASS_EFFECTS.COLORS.DEFAULT_BG}

      className={`w-150 h-45 rounded-2xl shadow-2xl hover:scale-105 transition-transform duration-200 ${

        error ? "border border-red-500/30" : ""

      }`}

    >

      <div className="p-5 text-white flex flex-col flex-start h-full">

        <div className="flex items-center justify-between mb-3">

          <h3 className="text-base font-semibold opacity-90">Live Caption</h3>

          <div className="flex items-center space-x-2">

            <div className={`w-2 h-2 rounded-full ${color}`} />

            <span className="text-sm opacity-70">{label}</span>

          </div>

        </div>



        <div className="min-h-[4rem] flex flex-col">

          {content ? (

            <div className={`text-sm opacity-85 leading-relaxed flex-1 ${error ? "text-red-300" : ""}`}>

              <span>{content || PROMPTS.fallbackCaption}</span>

            </div>

          ) : (

            <div className="flex items-center justify-center w-full space-x-2">

              <div className="animate-spin rounded-full h-4 w-4 border border-blue-400 border-t-transparent" />

              <p className="text-sm opacity-80 italic">{PROMPTS.processingMessage}</p>

            </div>

          )}

        </div>

      </div>

    </GlassContainer>
  );
}