-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: In this conversation, we worked on designing and refining th…
…e Navbar for your React app. We started from the basic code and made adjustments to ensure it is fixed at the top of the page with a user dropdown menu. We added visual effects like hover color changes and made the layout responsive to adapt to different screen sizes. Description: 1- Fixed Logo: A fixed logo on the left side with hover effects. 2- Navigation Links: Links for different app pages with hover color transitions. 3- User Dropdown Menu: A clickable user icon revealing options like "Manage Account" and "Logout." 4- Responsive Design: Ensured that the Navbar adapts to smaller screen sizes for a smooth mobile experience.
- Loading branch information
1 parent
83c4049
commit fa8f071
Showing
6 changed files
with
378 additions
and
105 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Navbar.js | ||
import React, { useState } from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import styles from "./Navbar.module.css"; | ||
|
||
const Navbar = ({ user }) => { | ||
const navigate = useNavigate(); | ||
const [showDropdown, setShowDropdown] = useState(false); | ||
|
||
const toggleDropdown = () => { | ||
setShowDropdown((prev) => !prev); | ||
}; | ||
|
||
return ( | ||
<nav className={styles.navbar}> | ||
<h1 className={styles.logo} onClick={() => navigate("/")}> | ||
Logo | ||
</h1> | ||
<ul className={styles.nav_links}> | ||
<li onClick={() => navigate("/chatbot")}>Chatbot</li> | ||
<li onClick={() => navigate("/reminder")}>Reminder</li> | ||
<li onClick={() => navigate("/plan")}>Plan & Bay Chart</li> | ||
<li onClick={() => navigate("/about")}>About Us</li> | ||
<li onClick={() => navigate("/contact")}>Contact Us</li> | ||
</ul> | ||
<div className={styles.user_menu} onClick={toggleDropdown}> | ||
<div className={styles.user_icon}> | ||
<i className={`fas fa-${user ? "user" : "female"} fa-1x`}></i> | ||
</div> | ||
{showDropdown && ( | ||
<div className={styles.dropdown_content}> | ||
<a href="#">Manage Account</a> | ||
<a onClick={() => alert("Logging out...")}>Logout</a> | ||
</div> | ||
)} | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Navbar; |
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,93 @@ | ||
/* Navbar.module.css */ | ||
|
||
.navbar { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 15px 30px; | ||
background-color: #333; | ||
color: white; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
.logo { | ||
font-size: 24px; | ||
font-weight: bold; | ||
cursor: pointer; | ||
color: white; | ||
text-transform: uppercase; | ||
} | ||
|
||
.nav_links { | ||
display: flex; | ||
list-style: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.nav_links li { | ||
margin-left: 20px; | ||
cursor: pointer; | ||
font-size: 16px; | ||
transition: color 0.3s; | ||
} | ||
|
||
.nav_links li:hover { | ||
color: #4CAF50; | ||
} | ||
|
||
.user_menu { | ||
position: relative; | ||
cursor: pointer; | ||
} | ||
|
||
.user_icon { | ||
font-size: 22px; | ||
color: white; | ||
} | ||
|
||
.dropdown_content { | ||
position: absolute; | ||
top: 30px; | ||
right: 0; | ||
background-color: #fff; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
border-radius: 8px; | ||
padding: 10px; | ||
z-index: 10; | ||
} | ||
|
||
.dropdown_content a { | ||
display: block; | ||
padding: 8px 15px; | ||
text-decoration: none; | ||
color: #333; | ||
font-size: 16px; | ||
transition: background-color 0.3s; | ||
} | ||
|
||
.dropdown_content a:hover { | ||
background-color: #f1f1f1; | ||
} | ||
|
||
.favourited { | ||
color: #ff6347; | ||
} | ||
|
||
@media (max-width: 768px) { | ||
.navbar { | ||
flex-direction: column; | ||
align-items: flex-start; | ||
} | ||
|
||
.nav_links { | ||
flex-direction: column; | ||
margin-top: 10px; | ||
} | ||
|
||
.nav_links li { | ||
margin-left: 0; | ||
margin-bottom: 10px; | ||
} | ||
} | ||
|
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.