Skip to content

Commit 43f172e

Browse files
committed
UI complete
1 parent 121c702 commit 43f172e

2 files changed

Lines changed: 60 additions & 7 deletions

File tree

chat-app/client/src/App.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.messages {
2+
list-style: none;
3+
}
4+
5+
.message {
6+
margin-bottom: 0.5em;
7+
}
8+
9+
.chat-box {
10+
position: fixed;
11+
bottom: 0;
12+
left: 0;
13+
right: 0;
14+
padding: 16px;
15+
display: flex;
16+
height: 7vh;
17+
gap: 8px;
18+
}
19+
20+
.chat-input {
21+
flex: 1;
22+
border-radius: 8px;
23+
border: 1px solid #777;
24+
}
25+
26+
.send-button {
27+
background-color: #12bc00;
28+
color: #fff;
29+
border-radius: 8px;
30+
border: none;
31+
}
32+
33+
@media screen and (min-width: 800px) {
34+
.container {
35+
margin: auto 30%;
36+
}
37+
.chat-box {
38+
height: 5vh;
39+
left: 25%;
40+
right: 25%;
41+
}
42+
}

chat-app/client/src/App.jsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useState } from "react";
22
import useSocket from "./hooks/useSocket";
3+
import "./App.css";
34

45
export default function App() {
56
const { messages, sendMessage } = useSocket("http://localhost:3000");
@@ -10,16 +11,26 @@ export default function App() {
1011
sendMessage(input.trim());
1112
setInput("");
1213
};
13-
14+
1415
return (
15-
<div>
16-
<ul>
17-
{messages.map((msg, i) => (
18-
<li key={i}>{msg.text}</li>
16+
<div className="container">
17+
<ul className="messages">
18+
{messages.map((message, i) => (
19+
<li className="message" key={i}>
20+
{message.text}
21+
</li>
1922
))}
2023
</ul>
21-
<input value={input} onChange={(e) => setInput(e.target.value)} />
22-
<button onClick={handleSend}>Send</button>
24+
<div className="chat-box">
25+
<input
26+
className="chat-input"
27+
value={input}
28+
onChange={(e) => setInput(e.target.value)}
29+
/>
30+
<button className="send-button" onClick={handleSend}>
31+
Send
32+
</button>
33+
</div>
2334
</div>
2435
);
2536
}

0 commit comments

Comments
 (0)