diff --git a/client/app.css b/client/app.css index 016c256..09fb38e 100644 --- a/client/app.css +++ b/client/app.css @@ -66,11 +66,23 @@ body { box-shadow: rgb( 0, 0, 0, 0.6) 6px 45px 45px -12px; } -.chat { +.chat-container { border-bottom: 1px solid #d65d0e; height: 200px; - overflow-y: scroll; padding-bottom: 12px; + display: flex; + flex-direction: row; + min-height: min-content; +} + +.chat-box { + flex: 3; + overflow-y: scroll; +} + +.chat-connections { + flex: 1; + overflow-y: scroll; } * { @@ -116,4 +128,5 @@ body { color: #8ec07c; border-radius: 8px; display: inline-block; -} \ No newline at end of file +} + diff --git a/client/components/chatroom/_chat_room.jsx b/client/components/chatroom/_chat_room.jsx index e70715c..22fb399 100644 --- a/client/components/chatroom/_chat_room.jsx +++ b/client/components/chatroom/_chat_room.jsx @@ -1,6 +1,6 @@ import { useEffect, useState, useContext } from 'react'; import { ApiContext } from '../../utils/api_context'; -import { useMessages } from '../../utils/use_messages'; +import { useChat } from '../../utils/use_chat'; import { Link, useParams } from 'react-router-dom'; import { generateGruvboxFromString } from '../../utils/generate_gruvbox'; @@ -11,7 +11,7 @@ import { generateGruvboxFromString } from '../../utils/generate_gruvbox'; export const ChatRoom = () => { const { id } = useParams(); const [chatRoom, setChatRoom] = useState(''); - const [messages, sendMessage] = useMessages(chatRoom); + const [connections, messages, sendMessage] = useChat(chatRoom); const [message, setMessage] = useState(''); const [color, setColor] = useState(generateGruvboxFromString('placeholder')); const [user, setUser] = useState({}); @@ -56,14 +56,26 @@ export const ChatRoom = () => {

{chatRoom?.name || `Chat Room ${chatRoom?.id}`}

-
-

Welcome!

- {messages.map((message) => ( -
- {message.userName}: - {message.content} -
- ))} +
+
+ {messages.map((message) => ( +
+ {message.userName}: + {message.content} +
+ ))} +
+
+

Connected Users ({connections.length})

+
+
    + {connections.map((user) => ( +
  • + {user.userName} +
  • + ))} +
+