-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrontend-App.jsx
More file actions
148 lines (134 loc) · 4.96 KB
/
Frontend-App.jsx
File metadata and controls
148 lines (134 loc) · 4.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// App.jsx (Frontend - React + Tailwind CSS + Framer Motion + Dynamic Features + Auth)
import React from 'react';
import { BrowserRouter as Router, Route, Routes, Link } from 'react-router-dom';
import { motion } from 'framer-motion';
import Home from './pages/Home';
import Profile from './pages/Profile';
import Connections from './pages/Connections';
import SignIn from './pages/SignIn';
import SignOut from './pages/SignOut';
import Posts from './pages/Posts';
import Meet from './pages/Meet';
const Navbar = () => (
<nav className="bg-white shadow-md py-4 px-8 flex justify-between items-center sticky top-0 z-50">
<h1 className="text-2xl font-bold text-indigo-600">DevConnect</h1>
<div className="space-x-6">
<Link to="/" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Home</Link>
<Link to="/profile" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Profile</Link>
<Link to="/connections" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Connections</Link>
<Link to="/posts" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Posts</Link>
<Link to="/meet" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Meet</Link>
<Link to="/signin" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Sign In</Link>
<Link to="/signout" className="text-gray-700 hover:text-indigo-600 font-medium transition-all duration-200">Sign Out</Link>
</div>
</nav>
);
const App = () => (
<Router>
<Navbar />
<motion.div
className="p-8 max-w-7xl mx-auto"
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6 }}
>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/profile" element={<Profile />} />
<Route path="/connections" element={<Connections />} />
<Route path="/posts" element={<Posts />} />
<Route path="/meet" element={<Meet />} />
<Route path="/signin" element={<SignIn />} />
<Route path="/signout" element={<SignOut />} />
</Routes>
</motion.div>
</Router>
);
export default App;
// pages/Posts.jsx
import React, { useState } from 'react';
const Posts = () => {
const [posts, setPosts] = useState([]);
const [content, setContent] = useState('');
const [image, setImage] = useState(null);
const [previewImage, setPreviewImage] = useState(null);
const handleImageChange = (e) => {
const file = e.target.files[0];
if (file) {
setImage(file);
setPreviewImage(URL.createObjectURL(file));
}
};
const handlePost = () => {
const newPost = {
id: posts.length + 1,
content,
image: previewImage,
date: new Date().toLocaleString()
};
setPosts([newPost, ...posts]);
setContent('');
setImage(null);
setPreviewImage(null);
};
return (
<div className="space-y-6">
<h2 className="text-3xl font-bold text-indigo-600">Create a Post</h2>
<textarea
value={content}
onChange={(e) => setContent(e.target.value)}
placeholder="What's on your mind?"
className="w-full border border-gray-300 rounded-xl p-4"
rows={4}
/>
<input
type="file"
accept="image/*"
onChange={handleImageChange}
className="mb-4"
/>
{previewImage && (
<img src={previewImage} alt="Preview" className="w-full h-auto rounded-xl mb-4" />
)}
<button
onClick={handlePost}
className="bg-indigo-600 text-white py-2 px-6 rounded-xl hover:bg-indigo-700 font-semibold"
>
Post
</button>
<div className="mt-8 space-y-6">
<h3 className="text-2xl font-semibold text-gray-800">Recent Posts</h3>
{posts.map((post) => (
<div
key={post.id}
className="bg-white shadow-md rounded-xl p-6 space-y-2"
>
<p className="text-gray-800 whitespace-pre-wrap">{post.content}</p>
{post.image && (
<img src={post.image} alt="post" className="w-full h-auto rounded-xl" />
)}
<p className="text-sm text-gray-500">Posted on {post.date}</p>
</div>
))}
</div>
</div>
);
};
export default Posts;
// pages/Meet.jsx
import React from 'react';
const Meet = () => {
return (
<div className="space-y-6">
<h2 className="text-3xl font-bold text-indigo-600">Start a Meet</h2>
<p className="text-gray-700">Use the button below to launch a video meet with others. We use an embedded Jitsi Meet instance.</p>
<iframe
src="https://meet.jit.si/DevConnectRoom"
allow="camera; microphone; fullscreen; display-capture"
style={{ width: '100%', height: '600px', border: '0px' }}
title="DevConnect Video Meet"
></iframe>
</div>
);
};
export default Meet;