Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#13 added active tab feature in navbar #16

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import About from './pages/About';
function App() {
return (
<>
<Navbar />
<Router>
<Navbar />
<Routes>
<Route path="/" element={<LandingPage />} />
<Route path="/bash" element={<EventsPage />} />
Expand Down
33 changes: 16 additions & 17 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
import "../styles/navbar.css";
import Logo from "../assets/logos/biz.jpg";
import { Link, useLocation } from "react-router-dom";

const Navbar = () => {
const location = useLocation();

return (
<nav className="navbar">
<div className="navbar-container">
<div className="navbar-logo">
<a href="/">
{" "}
<img className="w-12 h-12 rounded-full" src={Logo} />
</a>{" "}
<Link to="/">
<img className="w-12 h-12 rounded-full" src={Logo} alt="Business Club Logo" />
</Link>
</div>

<div className="navbar-links">
<a href="/" className="nav-link">
<Link to="/" className={`nav-link ${location.pathname === "/" ? "active" : ""}`}>
HOME
</a>
<a href="/timeline" className="nav-link">
</Link>
<Link to="/timeline" className={`nav-link ${location.pathname === "/timeline" ? "active" : ""}`}>
TIMELINE
</a>
<a
href="https://linktr.ee/businessclub_iitbhu"
target="_blank"
className="nav-link"
>
</Link>
<a href="https://linktr.ee/businessclub_iitbhu" target="_blank" className="nav-link">
RESOURCES
</a>
<a href="/bash" className="nav-link">
<Link to="/bash" className={`nav-link ${location.pathname === "/bash" ? "active" : ""}`}>
BASH
</a>
<a href="/newsletter" className="nav-link">
</Link>
<Link to="/newsletter" className={`nav-link ${location.pathname === "/newsletter" ? "active" : ""}`}>
NEWSLETTER
</a>
</Link>
</div>
</div>
</nav>
Expand Down
28 changes: 16 additions & 12 deletions src/styles/navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@

.nav-link {
@apply text-gray-800 text-sm font-medium relative py-1 transition-all duration-300;
/* Custom underline hover effect */
&::after {
content: '';
@apply absolute left-0 bottom-0 w-0 h-[1px] bg-black transition-all duration-300;
}
&:hover::after {
@apply w-full;
}
&:hover {
@apply text-black;
}
}
}

.nav-link::after {
content: "";
@apply absolute left-0 bottom-0 w-0 h-[1px] bg-black transition-all duration-300;
}

.nav-link:hover::after,
.nav-link.active::after {
@apply w-full;
}

.nav-link:hover,
.nav-link.active {
@apply text-black font-bold;
}