Skip to content

Commit

Permalink
Merge pull request #533 from s2sharpit/activePage
Browse files Browse the repository at this point in the history
feat: Adding active page indicator in Navbar
  • Loading branch information
mkubdev authored Sep 25, 2023
2 parents e8f3bfe + cf27ca4 commit 7997a05
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/main-nav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { cn } from "@/lib/utils";
import { NavItem } from "@/types/nav";
import Image from "next/image";
import Link from "next/link";
import { usePathname } from 'next/navigation';
import { useEffect, useRef, useState } from "react";
import { BiMenuAltRight } from "react-icons/bi";
import { MdOutlineClose } from "react-icons/md";
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

1 comment on commit 7997a05

@vercel
Copy link

@vercel vercel bot commented on 7997a05 Sep 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.