Skip to content
This repository was archived by the owner on Sep 19, 2025. It is now read-only.

Commit ff475f2

Browse files
highlight active navigation item in LeftSidebar
1 parent e61baf9 commit ff475f2

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/frontend/components/layout/LeftSidebar.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type React from 'react';
22
import { useState, useEffect, useMemo } from 'react';
3+
import { useLocation } from 'react-router-dom';
34
import {
45
HomeIcon,
56
BookmarkIcon,
@@ -33,15 +34,21 @@ interface NavItemProps {
3334

3435
const NavItem: React.FC<NavItemProps> = ({ icon, label, to, active, onClick, title, hasDropdown, dropdownContent }) => {
3536
const [isOpen, setIsOpen] = useState(false);
37+
const location = useLocation();
3638

37-
const buttonContent = (
39+
40+
const isActive = location.pathname === to;
41+
42+
43+
const buttonContent = (
3844
<Button
3945
variant="ghost"
4046
onClick={hasDropdown ? () => setIsOpen(!isOpen) : onClick}
4147
size="icon"
4248
className={cn(
4349
"w-full flex flex-col items-center justify-center py-2 px-1 h-auto",
4450
"hover-primary-effect rounded-none transition-all duration-200",
51+
isActive && "bg-primary/10",
4552
)}
4653
>
4754
<div className="mb-1">{icon}</div>

0 commit comments

Comments
 (0)