Skip to content

Commit 5284fb2

Browse files
author
Uttam Singh
committed
Improved navbar design, logo visibility, and text contrast
1 parent bafd812 commit 5284fb2

File tree

1 file changed

+122
-22
lines changed

1 file changed

+122
-22
lines changed

frontend/src/pages/AdminDashboard.jsx

Lines changed: 122 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect } from "react";
1+
import React, { useState, useEffect, useRef } from "react";
22

33
export default function AdminDashboard() {
44
const [formData, setFormData] = useState({
@@ -11,6 +11,8 @@ export default function AdminDashboard() {
1111
});
1212
const [message, setMessage] = useState("");
1313
const [users, setUsers] = useState([]);
14+
const [dropdownOpen, setDropdownOpen] = useState(false);
15+
const dropdownRef = useRef(null);
1416

1517
const handleChange = (e) =>
1618
setFormData({ ...formData, [e.target.name]: e.target.value });
@@ -62,35 +64,78 @@ export default function AdminDashboard() {
6264
fetchUsers();
6365
}, []);
6466

67+
useEffect(() => {
68+
const handleClickOutside = (event) => {
69+
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
70+
setDropdownOpen(false);
71+
}
72+
};
73+
document.addEventListener("mousedown", handleClickOutside);
74+
return () => document.removeEventListener("mousedown", handleClickOutside);
75+
}, []);
76+
77+
const handleLogout = () => {
78+
localStorage.removeItem("user");
79+
window.location.href = "/";
80+
};
81+
6582
return (
6683
<div style={styles.container}>
67-
{/* TOP NAVBAR */}
84+
{/* ====== STICKY NAVBAR ====== */}
6885
<nav style={styles.navbar}>
6986
<div style={styles.logoSection}>
7087
<img
71-
src="https://upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Blue_circle_logo.svg/120px-Blue_circle_logo.svg.png"
72-
alt="logo"
88+
src="https://i.ibb.co/BcQX07D/edme-logo-white.png" // Replace with your logo if needed
89+
alt="FAT-EIBL Logo"
7390
style={styles.logo}
7491
/>
7592
<span style={styles.logoText}>FAT-EIBL</span>
7693
</div>
94+
7795
<div style={styles.navLinks}>
78-
<a href="#" style={styles.linkActive}>Dashboard</a>
79-
<a href="#">Users</a>
80-
<a href="#">Departments</a>
81-
<a href="#">Reports</a>
82-
<a href="#">Settings</a>
96+
<a href="#" style={{ ...styles.navLinksBase, ...styles.linkActive }}>
97+
Dashboard
98+
</a>
99+
<a href="#" style={styles.navLinksBase}>
100+
Users
101+
</a>
102+
<a href="#" style={styles.navLinksBase}>
103+
Departments
104+
</a>
105+
<a href="#" style={styles.navLinksBase}>
106+
Reports
107+
</a>
108+
<a href="#" style={styles.navLinksBase}>
109+
Settings
110+
</a>
111+
</div>
112+
113+
<div style={styles.userSection} ref={dropdownRef}>
114+
<img
115+
src="https://cdn-icons-png.flaticon.com/512/847/847969.png"
116+
alt="User Avatar"
117+
style={styles.avatar}
118+
onClick={() => setDropdownOpen(!dropdownOpen)}
119+
/>
120+
{dropdownOpen && (
121+
<div style={styles.dropdown}>
122+
<p style={styles.dropdownItem}>👤 Admin</p>
123+
<hr style={styles.dropdownDivider} />
124+
<button style={styles.logoutBtn} onClick={handleLogout}>
125+
🚪 Logout
126+
</button>
127+
</div>
128+
)}
83129
</div>
84130
</nav>
85131

86-
{/* MAIN CONTENT */}
132+
{/* ====== MAIN CONTENT ====== */}
87133
<main style={styles.main}>
88134
<h1 style={styles.title}>Admin Dashboard</h1>
89135
<p style={styles.subtitle}>
90136
Manage users, departments, and system access.
91137
</p>
92138

93-
{/* FORM CARD */}
94139
<div style={styles.card}>
95140
<h2 style={styles.cardTitle}>Create New User</h2>
96141
<form onSubmit={handleSubmit} style={styles.form}>
@@ -114,6 +159,7 @@ export default function AdminDashboard() {
114159
required
115160
/>
116161
</div>
162+
117163
<div style={styles.row}>
118164
<input
119165
type="password"
@@ -133,6 +179,7 @@ export default function AdminDashboard() {
133179
style={styles.input}
134180
/>
135181
</div>
182+
136183
<div style={styles.row}>
137184
<input
138185
type="email"
@@ -176,7 +223,6 @@ export default function AdminDashboard() {
176223
)}
177224
</div>
178225

179-
{/* USER LIST */}
180226
<div style={styles.tableCard}>
181227
<h3 style={styles.tableTitle}>Registered Users</h3>
182228
{users.length === 0 ? (
@@ -224,39 +270,93 @@ const styles = {
224270
minHeight: "100vh",
225271
},
226272
navbar: {
273+
position: "sticky",
274+
top: 0,
275+
zIndex: 1000,
227276
display: "flex",
228277
justifyContent: "space-between",
229278
alignItems: "center",
230-
backgroundColor: "#004aad",
231-
color: "white",
279+
backgroundColor: "#003a85",
280+
color: "#f0f4ff",
232281
padding: "10px 40px",
233-
boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
282+
boxShadow: "0 3px 10px rgba(0,0,0,0.1)",
234283
},
235284
logoSection: {
236285
display: "flex",
237286
alignItems: "center",
238-
gap: "12px",
287+
gap: "10px",
239288
},
240289
logo: {
241-
width: "35px",
242-
height: "35px",
243-
borderRadius: "50%",
244-
backgroundColor: "white",
245-
objectFit: "cover",
290+
width: "42px",
291+
height: "42px",
292+
objectFit: "contain",
293+
backgroundColor: "transparent",
246294
},
247295
logoText: {
248-
fontSize: "1.3rem",
296+
fontSize: "1.4rem",
249297
fontWeight: "700",
298+
color: "#ffffff",
250299
letterSpacing: "0.5px",
251300
},
252301
navLinks: {
253302
display: "flex",
254303
gap: "30px",
304+
alignItems: "center",
305+
},
306+
navLinksBase: {
307+
color: "#dbe9ff",
308+
textDecoration: "none",
309+
fontWeight: "500",
310+
fontSize: "1rem",
311+
transition: "color 0.2s ease",
255312
},
256313
linkActive: {
314+
color: "#ffffff",
257315
fontWeight: "600",
258316
textDecoration: "underline",
259317
},
318+
userSection: {
319+
position: "relative",
320+
cursor: "pointer",
321+
},
322+
avatar: {
323+
width: "40px",
324+
height: "40px",
325+
borderRadius: "50%",
326+
border: "2px solid #f0f4ff",
327+
boxShadow: "0 0 6px rgba(255,255,255,0.6)",
328+
},
329+
dropdown: {
330+
position: "absolute",
331+
right: 0,
332+
top: "50px",
333+
backgroundColor: "white",
334+
color: "#003b80",
335+
borderRadius: "10px",
336+
boxShadow: "0 3px 12px rgba(0,0,0,0.15)",
337+
minWidth: "150px",
338+
overflow: "hidden",
339+
zIndex: 2000,
340+
},
341+
dropdownItem: {
342+
padding: "10px 15px",
343+
margin: 0,
344+
fontSize: "0.95rem",
345+
},
346+
dropdownDivider: {
347+
margin: 0,
348+
borderColor: "#eee",
349+
},
350+
logoutBtn: {
351+
width: "100%",
352+
textAlign: "left",
353+
background: "none",
354+
border: "none",
355+
padding: "10px 15px",
356+
color: "#e11d48",
357+
cursor: "pointer",
358+
fontSize: "0.95rem",
359+
},
260360
main: {
261361
padding: "40px 80px",
262362
},

0 commit comments

Comments
 (0)