Skip to content

Commit 422befa

Browse files
Update Button
1 parent 886e1a0 commit 422befa

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

src/features/Assistant/VapiButton.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,47 @@
11
import { CALL_STATUS, useVapi } from "./useVapi";
2-
import { Loader2 } from "lucide-react";
2+
import { Loader2, Mic, Square } from "lucide-react";
33

44
const VapiButton = ({
55
toggleCall,
66
callStatus,
77
audioLevel = 0,
88
}: Partial<ReturnType<typeof useVapi>>) => {
9+
const color =
10+
callStatus === CALL_STATUS.ACTIVE
11+
? "red"
12+
: callStatus === CALL_STATUS.LOADING
13+
? "orange"
14+
: "green";
915
const buttonStyle = {
1016
borderRadius: "50%",
1117
width: "50px",
1218
height: "50px",
1319
color: "white",
1420
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}`,
1624
cursor: "pointer",
1725
};
1826

1927
return (
2028
<button
2129
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`}
2337
onClick={toggleCall}
2438
>
2539
{callStatus === CALL_STATUS.ACTIVE ? (
26-
"Stop"
40+
<Square />
2741
) : callStatus === CALL_STATUS.LOADING ? (
2842
<Loader2 className="animate-spin" />
2943
) : (
30-
"Play"
44+
<Mic />
3145
)}
3246
</button>
3347
);

0 commit comments

Comments
 (0)
close