Skip to content

Commit

Permalink
style: navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhish7k committed Jul 27, 2024
1 parent 7376162 commit 183f0ff
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"use client";

import Link from "next/link";
import React from "react";
import React, { useEffect, useState } from "react";
import Image from "next/image";
import { ModeToggle } from "./ModeToggle";
import { Button } from "../components/ui/button";
Expand All @@ -15,8 +17,32 @@ import {
import { AlignJustify } from "lucide-react";

const Navbar = () => {
const [scrolled, setScrolled] = useState(false);

useEffect(() => {
const handleScroll = () => {
const offset = window.scrollY;
if (offset > 50) {
setScrolled(true);
} else {
setScrolled(false);
}
};

window.addEventListener("scroll", handleScroll);
return () => {
window.removeEventListener("scroll", handleScroll);
};
}, []);

if (scrolled) console.log("scroll triggered");

return (
<div className="sticky top-0 z-50 py-4 px-5 md:px-[5%] xl:px-[10%] flex items-center justify-between bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 transition-all">
<div
className={`sticky top-0 z-50 py-4 px-5 md:px-[5%] xl:px-[10%] flex items-center justify-between bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 transition-all
${scrolled ? "border-b" : ""}
`}
>
{/* Logo */}
<div className="flex items-center">
<Link href="/" className="flex items-center gap-2">
Expand Down

0 comments on commit 183f0ff

Please sign in to comment.