-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from Shaurya0108/develop
Develop
- Loading branch information
Showing
43 changed files
with
192 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default function Menu() { | ||
|
||
return ( | ||
<div>Menu page</div> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,94 @@ | ||
import { useState, useEffect, useRef } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import UTDIcon from "../images/UTD Icon.png"; | ||
import MenuIcon from "../icons/MenuIcon.svg"; | ||
import SettingsIcon from "../icons/SettingsIcon.svg"; | ||
|
||
export default function Navbar() { | ||
const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
const [isSettingsDropdownOpen, setIsSettingsDropdownOpen] = useState(false); | ||
const [isSettingsIconRotated, setIsSettingsIconRotated] = useState(false); | ||
const [isMenuDropdownOpen, setIsMenuDropdownOpen] = useState(false); | ||
const [isMenuIconRotated, setIsMenuIconRotated] = useState(false); | ||
const dropdownRef = useRef(null); | ||
const navigate = useNavigate(); | ||
|
||
const toggleDropdown = () => setIsDropdownOpen(!isDropdownOpen); | ||
const toggleMenuDropdown = () => { | ||
setIsMenuDropdownOpen(!isMenuDropdownOpen); | ||
setIsMenuIconRotated(!isMenuIconRotated); | ||
} | ||
const toggleSettingsDropdown = () => { | ||
setIsSettingsDropdownOpen(!isSettingsDropdownOpen); | ||
setIsSettingsIconRotated(!isSettingsIconRotated); | ||
} | ||
|
||
const handleSettingsClick = () => { | ||
toggleDropdown(); | ||
navigate('/settings'); | ||
const handleSyllabusClick = () => { | ||
navigate('/syllabus'); | ||
}; | ||
|
||
const handleHomeworkClick = () => { | ||
navigate('/homework'); | ||
}; | ||
|
||
const handleProfileClick = () => { | ||
navigate('/profile'); | ||
}; | ||
|
||
const handleLogoutClick = () => { | ||
toggleDropdown(); | ||
navigate('/'); | ||
navigate('/logout'); | ||
}; | ||
|
||
const handleHelpClick = () => { | ||
navigate('/help'); | ||
}; | ||
|
||
useEffect(() => { | ||
function handleClickOutside(event) { | ||
if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { | ||
setIsDropdownOpen(false); | ||
setIsMenuDropdownOpen(false); | ||
setIsSettingsDropdownOpen(false); | ||
} | ||
} | ||
|
||
if (isDropdownOpen) { | ||
if (isSettingsDropdownOpen || isMenuDropdownOpen) { | ||
document.addEventListener('mousedown', handleClickOutside); | ||
} | ||
|
||
return () => { | ||
document.removeEventListener('mousedown', handleClickOutside); | ||
}; | ||
}, [isDropdownOpen]); | ||
}, [isSettingsDropdownOpen, isMenuDropdownOpen]); | ||
|
||
return ( | ||
<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> | ||
<button className="menu-button" onClick={toggleMenuDropdown}> | ||
<img src={MenuIcon} alt="Menu Icon" className={`menu-icon ${isMenuIconRotated ? 'rotate' : ''}`} /> | ||
</button> | ||
{isMenuDropdownOpen && ( | ||
<div ref={dropdownRef} className="dropdown-menu absolute left-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={handleSyllabusClick}>Syllabus</a> | ||
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleHomeworkClick}>Homework</a> | ||
</div> | ||
)} | ||
|
||
<div className="center-container"> | ||
<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> | ||
</div> | ||
<button className="settings-button" onClick={toggleDropdown}></button> | ||
{isDropdownOpen && ( | ||
|
||
<button className="settings-button" onClick={toggleSettingsDropdown}> | ||
<img src={SettingsIcon} alt="Settings Icon" className={`settings-icon ${isSettingsIconRotated ? 'rotate' : ''}`} /> | ||
</button> | ||
{isSettingsDropdownOpen && ( | ||
<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={handleProfileClick}>Profile</a> | ||
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleLogoutClick}>Logout</a> | ||
<a href="#" className="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" onClick={handleHelpClick}>Help</a> | ||
</div> | ||
)} | ||
|
||
</nav> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Diff not rendered.
Diff not rendered.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.