Skip to content

Commit 3c9d07a

Browse files
authored
Merge pull request #20 from ADARSHsri2004/feat/socket
feat: setup for socket.io done
2 parents c58e801 + 3636e79 commit 3c9d07a

File tree

10 files changed

+2483
-1534
lines changed

10 files changed

+2483
-1534
lines changed

client/package-lock.json

Lines changed: 137 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"lucide-react": "^0.545.0",
1919
"react": "^19.1.1",
2020
"react-dom": "^19.1.1",
21+
"socket.io-client": "^4.8.1",
2122
"sonner": "^2.0.7",
2223
"tailwind-merge": "^3.3.1",
2324
"tailwindcss": "^4.1.14"

client/src/App.jsx

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,44 @@
1+
import { useState } from "react";
12
import { Canvas } from "./components/Canvas";
23

34
function App() {
5+
const [roomId, setRoomId] = useState("");
6+
const [joined, setJoined] = useState(false);
7+
8+
const handleJoin = () => {
9+
if (!roomId.trim()) {
10+
alert("Please enter a valid Room ID");
11+
return;
12+
}
13+
setJoined(true);
14+
};
15+
416
return (
5-
<main className="w-full h-screen">
6-
<Canvas />
17+
<main className="w-full h-screen flex items-center justify-center bg-gray-100">
18+
{!joined ? (
19+
<div className="flex flex-col items-center gap-4 p-6 bg-white rounded-xl shadow-md">
20+
<h1 className="text-2xl font-bold text-gray-800">
21+
Join a Drawing Room
22+
</h1>
23+
<input
24+
type="text"
25+
placeholder="Enter Room ID"
26+
value={roomId}
27+
onChange={(e) => setRoomId(e.target.value)}
28+
className="border border-gray-300 rounded-lg px-4 py-2 text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500"
29+
/>
30+
<button
31+
onClick={handleJoin}
32+
className="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg font-medium transition-all"
33+
>
34+
Join Room
35+
</button>
36+
</div>
37+
) : (
38+
<Canvas roomId={roomId} />
39+
)}
740
</main>
8-
)
41+
);
942
}
1043

1144
export default App;

0 commit comments

Comments
 (0)