From 8069cb2925bcf34a63b5b1738f41e97c0385575b Mon Sep 17 00:00:00 2001 From: Gal Podlipnik Date: Thu, 12 Jun 2025 03:46:46 +0200 Subject: [PATCH] improvement --- frontend/src/components/ChatSidebar.tsx | 2 +- frontend/src/components/MessageInput.tsx | 122 +++++++++++++++++++---- 2 files changed, 104 insertions(+), 20 deletions(-) diff --git a/frontend/src/components/ChatSidebar.tsx b/frontend/src/components/ChatSidebar.tsx index e4a55eb..a303f51 100644 --- a/frontend/src/components/ChatSidebar.tsx +++ b/frontend/src/components/ChatSidebar.tsx @@ -188,7 +188,7 @@ export const ChatSidebar: FC = ({
- {getOnlineMembersCount(room) / room.members.length} + {getOnlineMembersCount(room)} / {room.members.length} online
diff --git a/frontend/src/components/MessageInput.tsx b/frontend/src/components/MessageInput.tsx index 3086764..38fd330 100644 --- a/frontend/src/components/MessageInput.tsx +++ b/frontend/src/components/MessageInput.tsx @@ -1,6 +1,6 @@ import { useSocket } from '@/hooks/useSocket'; -import { Send } from 'lucide-react'; -import { useEffect, useState, type FC, type FormEvent } from 'react'; +import { Mic, Paperclip, Send, Smile } from 'lucide-react'; +import { useEffect, useRef, useState, type FC, type FormEvent } from 'react'; import { toast } from 'sonner'; import { Button } from './ui/button'; import { Input } from './ui/input'; @@ -12,6 +12,9 @@ type MessageInputProps = { export const MessageInput: FC = ({ roomId }) => { const [message, setMessage] = useState(''); const [isRateLimited, setIsRateLimited] = useState(false); + const [showEmojiPicker, setShowEmojiPicker] = useState(false); + const [isFocused, setIsFocused] = useState(false); + const inputRef = useRef(null); const { socket } = useSocket(); useEffect(() => { @@ -50,24 +53,105 @@ export const MessageInput: FC = ({ roomId }) => { setMessage(''); }; + // Function to handle emoji selection (placeholder for now) + const handleEmojiClick = (emoji: string) => { + setMessage((prev) => prev + emoji); + inputRef.current?.focus(); + setShowEmojiPicker(false); + }; + return ( -
-
- setMessage(e.target.value)} - placeholder={ - isRateLimited - ? 'Rate limited - please wait...' - : 'Type your message...' - } - disabled={isRateLimited} - className="flex-1" - /> - -
+
+
+
+
+ + + + + setMessage(e.target.value)} + onFocus={() => setIsFocused(true)} + onBlur={() => setIsFocused(false)} + placeholder={ + isRateLimited + ? 'Rate limited - please wait...' + : 'Type your message...' + } + disabled={isRateLimited} + className="flex-1 border-0 focus-visible:ring-0 focus-visible:ring-offset-0 bg-transparent py-2 px-3" + /> + + {message.trim() ? ( + + ) : ( + + )} +
+ + {/* Emoji picker placeholder - you'd need to implement or use a library like emoji-mart */} + {showEmojiPicker && ( +
+
+ {['😀', '😂', '❤️', '👍', '🎉', '🔥', '👏', '😢'].map( + (emoji) => ( + + ) + )} +
+
+ )} +
+ + {isFocused && !isRateLimited && ( +
+ Press Enter to send + {message.length} / 2000 +
+ )} +
); };