tahamajs/IE / Projects /front /src /components /conference /ConferenceControls.tsx
tahamajs's picture
download
raw
4.55 kB
// src/components/conference/ConferenceControls.tsx
import { useEffect } from "react";
import {
Mic, MicOff, Video, VideoOff, MonitorUp, MonitorX,
MessageSquare, PhoneOff, Users, Circle,
} from "lucide-react";
import { toast } from "react-toastify";
interface ConferenceControlsProps {
isMuted: boolean;
isVideoOff: boolean;
isScreenSharing: boolean;
isChatOpen: boolean;
onToggleMute: () => void;
onToggleVideo: () => void;
onToggleScreenShare: () => void;
onToggleChat: () => void;
onEndCall: () => void;
onShowParticipants: () => void;
onRaiseHand?: () => void; // optional raise hand
isRecording?: boolean; // optional recording state
onToggleRecording?: () => void; // optional recording toggle
}
export function ConferenceControls({
isMuted, isVideoOff, isScreenSharing,
isChatOpen, onToggleMute, onToggleVideo,
onToggleScreenShare, onToggleChat, onEndCall, onShowParticipants,
onRaiseHand,
isRecording = false,
onToggleRecording,
}: ConferenceControlsProps) {
// Keyboard shortcuts
useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === "M") {
e.preventDefault();
onToggleMute();
toast.info(isMuted ? "Microphone unmuted" : "Microphone muted", { autoClose: 1000 });
}
if ((e.ctrlKey || e.metaKey) && e.shiftKey && e.key === "V") {
e.preventDefault();
onToggleVideo();
toast.info(isVideoOff ? "Video enabled" : "Video disabled", { autoClose: 1000 });
}
};
document.addEventListener("keydown", handleKeyDown);
return () => document.removeEventListener("keydown", handleKeyDown);
}, [isMuted, isVideoOff, onToggleMute, onToggleVideo]);
return (
<div className="bg-gray-900 border-t border-gray-700 px-4 py-3 flex items-center justify-center gap-4">
<ControlButton
onClick={onToggleMute}
active={isMuted}
icon={isMuted ? <MicOff className="w-5 h-5" /> : <Mic className="w-5 h-5" />}
label={isMuted ? "Unmute" : "Mute"}
tooltip="Ctrl+Shift+M"
/>
<ControlButton
onClick={onToggleVideo}
active={isVideoOff}
icon={isVideoOff ? <VideoOff className="w-5 h-5" /> : <Video className="w-5 h-5" />}
label={isVideoOff ? "Start Video" : "Stop Video"}
tooltip="Ctrl+Shift+V"
/>
<ControlButton
onClick={onToggleScreenShare}
active={isScreenSharing}
icon={isScreenSharing ? <MonitorX className="w-5 h-5" /> : <MonitorUp className="w-5 h-5" />}
label={isScreenSharing ? "Stop Sharing" : "Share Screen"}
tooltip="Share your screen"
/>
<ControlButton
onClick={onToggleChat}
active={isChatOpen}
icon={<MessageSquare className="w-5 h-5" />}
label="Chat"
tooltip="Toggle chat"
/>
<ControlButton
onClick={onShowParticipants}
active={false}
icon={<Users className="w-5 h-5" />}
label="People"
tooltip="Show participants"
/>
{onRaiseHand && (
<ControlButton
onClick={onRaiseHand}
active={false}
icon={<Circle className="w-5 h-5" />}
label="Raise Hand"
tooltip="Raise hand to speak"
/>
)}
{onToggleRecording && (
<ControlButton
onClick={onToggleRecording}
active={isRecording}
icon={<Circle className={`w-5 h-5 ${isRecording ? "text-red-500 animate-pulse" : ""}`} />}
label={isRecording ? "Stop Recording" : "Record"}
tooltip="Record conference (starts recording)"
/>
)}
<button
onClick={onEndCall}
className="bg-red-500 hover:bg-red-600 text-white p-3 rounded-full transition"
title="Leave"
>
<PhoneOff className="w-5 h-5" />
</button>
</div>
);
}
function ControlButton({
onClick, active, icon, label, tooltip,
}: {
onClick: () => void;
active: boolean;
icon: React.ReactNode;
label: string;
tooltip?: string;
}) {
return (
<button
onClick={onClick}
className={`p-3 rounded-full transition flex flex-col items-center ${
active
? "bg-red-600 text-white hover:bg-red-700"
: "bg-gray-700 text-white hover:bg-gray-600"
}`}
title={`${label} ${tooltip ? `(${tooltip})` : ""}`}
>
{icon}
<span className="text-[10px] mt-0.5 hidden sm:block">{label}</span>
</button>
);
}

Xet Storage Details

Size:
4.55 kB
·
Xet hash:
dda4fe10ffe3f32b0c996f2fd64903e8ae863bc4da1d14cf89601eab0107b0e8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.