UPDATE: Refactored ChatPanel and VideoPlayer layout for improved responsiveness and user experience

This commit is contained in:
Chris-1010
2025-02-01 15:20:35 +00:00
parent 2020b854f2
commit 7d11e81581
3 changed files with 17 additions and 16 deletions

View File

@@ -123,7 +123,7 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
<ToggleButton <ToggleButton
onClick={toggleChat} onClick={toggleChat}
toggled={isChatVisible} toggled={isChatVisible}
extraClasses="z-5" extraClasses="cursor-pointer"
> >
{isChatVisible ? "Hide Chat" : "Show Chat"} {isChatVisible ? "Hide Chat" : "Show Chat"}
</ToggleButton> </ToggleButton>
@@ -139,11 +139,8 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
{messages.map((msg, index) => ( {messages.map((msg, index) => (
<div <div
key={index} key={index}
className="grid grid-cols-[8%_minmax(15%,_100px)_1fr] items-center bg-gray-700 rounded p-2 text-white" className="grid grid-cols-[minmax(15%,_100px)_1fr] group h-fit items-center bg-gray-700 rounded p-2 text-white"
> >
<span className="text-gray-400 text-sm">
{new Date(msg.time_sent).toLocaleTimeString()}
</span>
<span <span
className={`font-bold ${ className={`font-bold ${
msg.chatter_username === username msg.chatter_username === username
@@ -154,13 +151,16 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
{" "} {" "}
{msg.chatter_username}:{" "} {msg.chatter_username}:{" "}
</span> </span>
<span>{msg.message}</span> <span className="text-center" >{msg.message}</span>
<span className="text-gray-400 text-sm scale-0 group-hover:scale-100 h-[0px] group-hover:h-[10px] transition-all delay-1000 group-hover:delay-200">
{new Date(msg.time_sent).toLocaleTimeString()}
</span>
</div> </div>
))} ))}
</div> </div>
<div className="flex justify-center gap-2"> <div className="flex justify-center gap-2">
{isLoggedIn && ( {isLoggedIn ? (
<> <>
<Input <Input
type="text" type="text"
@@ -181,13 +181,13 @@ const ChatPanel: React.FC<ChatPanelProps> = ({ streamId }) => {
Send Send
</button> </button>
</> </>
)} ) : (
{!isLoggedIn && (
<Button <Button
extraClasses="absolute top-[20px] left-[20px] text-[1rem] flex items-center flex-nowrap z-[999]" extraClasses="text-[1rem] flex items-center flex-nowrap z-[999]"
onClick={() => setShowAuthModal(true)} onClick={() => setShowAuthModal(true)}
></Button> >
Login to Chat
</Button>
)} )}
</div> </div>
{showAuthModal && ( {showAuthModal && (

View File

@@ -53,7 +53,7 @@ const VideoPlayer: React.FC<VideoPlayerProps> = ({ streamId }) => {
<div <div
id="video-container" id="video-container"
className="h-full flex items-center bg-gray-900 rounded-lg" className="h-full flex items-center bg-gray-900 rounded-lg"
style={{ gridArea: "2 / 1 / 3 / 2" }} style={{ gridArea: "1 / 1 / 2 / 2" }}
> >
<div ref={videoRef} id="video-player" className="w-full" /> <div ref={videoRef} id="video-player" className="w-full" />
</div> </div>

View File

@@ -77,18 +77,19 @@ const VideoPage: React.FC<VideoPageProps> = ({ streamId }) => {
<SocketProvider> <SocketProvider>
<div id="videoPage" className="w-full"> <div id="videoPage" className="w-full">
<Navbar /> <Navbar />
<div id="container" className="bg-gray-900"> <div id="container" className="grid grid-rows-[auto_1fr] grid-cols-[3fr_1fr] bg-gray-900">
<VideoPlayer streamId={streamId} /> <VideoPlayer streamId={streamId} />
<div <div
id="chat" id="chat"
className="relative top-0 right-0 bg-gray-800 bg-opacity-75 text-white p-4 w-1/3 h-full z-10 overflow-y-auto" className="relative top-0 right-0 w-full h-full bg-gray-800 bg-opacity-75 text-white p-4 w-1/3 z-10"
style={{ gridArea: "1 / 2 / 3 / 3" }}
> >
<ChatPanel streamId={streamId} /> <ChatPanel streamId={streamId} />
</div> </div>
<div <div
id="stream-info" id="stream-info"
className="flex flex-col gap-2 p-4 text-white" className="flex flex-col gap-2 p-4 text-white"
style={{ gridArea: "3 / 1 / 4 / 2" }} style={{ gridArea: "2 / 1 / 3 / 2" }}
> >
<h1 className="text-2xl font-bold"> <h1 className="text-2xl font-bold">
{streamData ? streamData.streamTitle : "Loading..."} {streamData ? streamData.streamTitle : "Loading..."}