Skip to content

Commit

Permalink
feat: Adding active page indicator in Navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
s2sharpit committed Sep 25, 2023
1 parent e8f3bfe commit 14148b9
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/main-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { cn } from "@/lib/utils";
import { NavItem } from "@/types/nav";
import Image from "next/image";
import Link from "next/link";
import { useEffect, useRef, useState } from "react";
import { usePathname } from 'next/navigation';
import { useEffect,useRef,useState } from "react";
import { BiMenuAltRight } from "react-icons/bi";
import { MdOutlineClose } from "react-icons/md";
import { ThemeToggle } from "./theme-toggle";
Expand All @@ -19,6 +20,7 @@ interface MainNavProps {
export function MainNav({ items }: MainNavProps) {
const [toggle, setToggle] = useState<boolean>(false);
const menuRef = useRef<HTMLDivElement>(null);
const pathname = usePathname();

useEffect(() => {
if (!toggle) return;
Expand Down Expand Up @@ -77,7 +79,8 @@ export function MainNav({ items }: MainNavProps) {
href={item.href}
className={cn(
"flex items-center whitespace-nowrap text-xl font-semibold sm:text-sm",
item.disabled && "cursor-not-allowed opacity-80"
item.disabled && "cursor-not-allowed opacity-80",
(item.href === pathname) && "text-purple-600"
)}
>
{item.title}
Expand Down

0 comments on commit 14148b9

Please sign in to comment.