File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change 1
1
import { CALL_STATUS , useVapi } from "./useVapi" ;
2
- import { Loader2 } from "lucide-react" ;
2
+ import { Loader2 , Mic , Square } from "lucide-react" ;
3
3
4
4
const VapiButton = ( {
5
5
toggleCall,
6
6
callStatus,
7
7
audioLevel = 0 ,
8
8
} : Partial < ReturnType < typeof useVapi > > ) => {
9
+ const color =
10
+ callStatus === CALL_STATUS . ACTIVE
11
+ ? "red"
12
+ : callStatus === CALL_STATUS . LOADING
13
+ ? "orange"
14
+ : "green" ;
9
15
const buttonStyle = {
10
16
borderRadius : "50%" ,
11
17
width : "50px" ,
12
18
height : "50px" ,
13
19
color : "white" ,
14
20
border : "none" ,
15
- boxShadow : `1px 1px ${ 10 + audioLevel * 40 } px ${ audioLevel * 10 } px orange` ,
21
+ boxShadow : `1px 1px ${ 10 + audioLevel * 40 } px ${
22
+ audioLevel * 10
23
+ } px ${ color } `,
16
24
cursor : "pointer" ,
17
25
} ;
18
26
19
27
return (
20
28
< button
21
29
style = { buttonStyle }
22
- className = "transition ease-in-out bg-orange-500 hover:bg-orange-700 flex items-center justify-center"
30
+ className = { `transition ease-in-out ${
31
+ callStatus === CALL_STATUS . ACTIVE
32
+ ? "bg-red-500 hover:bg-red-700"
33
+ : callStatus === CALL_STATUS . LOADING
34
+ ? "bg-orange-500 hover:bg-orange-700"
35
+ : "bg-green-500 hover:bg-green-700"
36
+ } flex items-center justify-center`}
23
37
onClick = { toggleCall }
24
38
>
25
39
{ callStatus === CALL_STATUS . ACTIVE ? (
26
- "Stop"
40
+ < Square />
27
41
) : callStatus === CALL_STATUS . LOADING ? (
28
42
< Loader2 className = "animate-spin" />
29
43
) : (
30
- "Play"
44
+ < Mic />
31
45
) }
32
46
</ button >
33
47
) ;
You can’t perform that action at this time.
0 commit comments