Skip to content

Commit

Permalink
Merge pull request #54 from Shaurya0108/settings
Browse files Browse the repository at this point in the history
Settings function, added drop down with logout and settings page
  • Loading branch information
xavierlmendez authored Nov 10, 2023
2 parents c690bb2 + f582d02 commit fc8716f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
2 changes: 2 additions & 0 deletions FrontEnd/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import './App.css'
import {Routes, Route} from 'react-router-dom';
import Login from './Login';
import Home from './Home'
import Settings from './Settings'

export default function App() {
return (

<Routes>
<Route path="/home" element={<Home/>} />
<Route path="/" element={<Login/>} />
<Route path="/settings" element={<Settings/>}/>
</Routes>
);
}
7 changes: 7 additions & 0 deletions FrontEnd/src/Settings.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function Settings() {

return (
<div>Settings page</div>
)
}

44 changes: 42 additions & 2 deletions FrontEnd/src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,54 @@
import { useState, useEffect, useRef } from 'react';
import { useNavigate } from 'react-router-dom';
import UTDIcon from "../images/UTD Icon.png";

export default function Navbar() {
const [isDropdownOpen, setIsDropdownOpen] = useState(false);
const dropdownRef = useRef(null);
const navigate = useNavigate();

const toggleDropdown = () => setIsDropdownOpen(!isDropdownOpen);

const handleSettingsClick = () => {
toggleDropdown();
navigate('/settings');
};

const handleLogoutClick = () => {
toggleDropdown();
navigate('/');
};

useEffect(() => {
function handleClickOutside(event) {
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
setIsDropdownOpen(false);
}
}

if (isDropdownOpen) {
document.addEventListener('mousedown', handleClickOutside);
}

return () => {
document.removeEventListener('mousedown', handleClickOutside);
};
}, [isDropdownOpen]);

return (
<nav className="nav flex items-center justify-between">
<nav className="nav flex items-center justify-between relative">
<img src={UTDIcon} className="utd-icon" alt="UTD Icon"></img>
<div className="navbar-caption text-center mx-auto">
<h1 className="navbar-cap-1 text-4xl font-bold">The Virtual Teacher Assistant</h1>
<h3 className="navbar-cap-2 text-xl">Advanced Algorithms Design and Analysis</h3>
</div>
<button className="settings-button"></button>
<button className="settings-button" onClick={toggleDropdown}></button>
{isDropdownOpen && (
<div ref={dropdownRef} className="dropdown-menu absolute right-0 top-20 mt-5 py-2 w-48 bg-white rounded-md shadow-xl z-50">
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleSettingsClick}>Settings</a>
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleLogoutClick}>Logout</a>
</div>
)}
</nav>
);
}

0 comments on commit fc8716f

Please sign in to comment.