Skip to content

Commit 9f0dc92

Browse files
committed
feat: added active tab highlighting
1 parent 9eebb08 commit 9f0dc92

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

frontend/components/TopBar.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"use client"
22

33
import { useState, useEffect } from 'react'
4-
import { User, ChevronDown, LogOut, Moon, Sun, AlertTriangle, Calculator, TrendingUp, FolderUp, GitCompare, Edit } from 'lucide-react'
4+
import { User, ChevronDown, LogOut, Moon, Sun, AlertTriangle, Calculator, TrendingUp, FolderUp, GitCompare, Edit, Menu } from 'lucide-react'
55
import { Button } from '@/components/ui/button'
66
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card'
77
import { Alert, AlertDescription } from '@/components/ui/alert'
@@ -58,32 +58,48 @@ export default function TopBar({ sidebarOpen, onToggleSidebar, activeTab, onTabC
5858
{
5959
title: "Calculate Tariff",
6060
icon: <Calculator className="h-full w-full" />,
61-
onClick: () => navigateToBaseAndChangeTab("calculate")
61+
onClick: () => navigateToBaseAndChangeTab("calculate"),
62+
isActive: pathname === '/' && activeTab === 'calculate'
6263
},
6364
// Admin-only: Manage Chatbot Documents tab
6465
...(isAdmin() ? [{
6566
title: "Manage Chatbot Documents",
6667
icon: <FolderUp className="h-full w-full" />,
67-
onClick: () => navigateToBaseAndChangeTab("manage-docs")
68+
onClick: () => navigateToBaseAndChangeTab("manage-docs"),
69+
isActive: pathname === '/' && activeTab === 'manage-docs'
6870
}] : []),
6971
// Admin-only: Tariff Management
7072
...(isAdmin() ? [{
7173
title: "Tariff Management",
7274
icon: <Edit className="h-full w-full" />,
73-
onClick: () => router.push('/edit')
75+
onClick: () => router.push('/edit'),
76+
isActive: pathname === '/edit'
7477
}] : []),
7578
{
7679
title: "Results",
7780
icon: <TrendingUp className="h-full w-full" />,
78-
onClick: () => router.push('/compare')
81+
onClick: () => router.push('/compare'),
82+
isActive: pathname === '/compare'
7983
},
8084
]
8185

8286
return (
8387
<>
8488
<header className="h-20 border-b border-slate-200 dark:border-slate-700 bg-white dark:bg-slate-800 flex items-center justify-center px-6 relative">
85-
{/* Left side - Empty spacer for balance */}
86-
<div className="absolute left-6 w-64"></div>
89+
{/* Left side - Logo and Burger Menu */}
90+
<div className="absolute left-6 flex items-center gap-3">
91+
{/* Burger Menu Button - Only show when sidebar is closed */}
92+
{!sidebarOpen && (
93+
<Button
94+
variant="ghost"
95+
size="sm"
96+
onClick={onToggleSidebar}
97+
className="text-slate-600 dark:text-slate-300 hover:bg-slate-100 dark:hover:bg-slate-700"
98+
>
99+
<Menu className="h-5 w-5" />
100+
</Button>
101+
)}
102+
</div>
87103

88104
{/* Center - Floating Dock Navigation */}
89105
<div className="flex justify-center">

frontend/components/ui/floating-dock.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const FloatingDock = ({
1818
desktopClassName,
1919
mobileClassName,
2020
}: {
21-
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void }[]
21+
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void; isActive?: boolean }[]
2222
desktopClassName?: string
2323
mobileClassName?: string
2424
}) => {
@@ -34,7 +34,7 @@ const FloatingDockMobile = ({
3434
items,
3535
className,
3636
}: {
37-
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void }[]
37+
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void; isActive?: boolean }[]
3838
className?: string
3939
}) => {
4040
const [open, setOpen] = useState(false)
@@ -107,7 +107,7 @@ const FloatingDockDesktop = ({
107107
items,
108108
className,
109109
}: {
110-
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void }[]
110+
items: { title: string; icon: React.ReactNode; href?: string; onClick?: () => void; isActive?: boolean }[]
111111
className?: string
112112
}) => {
113113
const mouseX = useMotionValue(Infinity)
@@ -133,12 +133,14 @@ function IconContainer({
133133
icon,
134134
href,
135135
onClick,
136+
isActive,
136137
}: {
137138
mouseX: MotionValue
138139
title: string
139140
icon: React.ReactNode
140141
href?: string
141142
onClick?: () => void
143+
isActive?: boolean
142144
}) {
143145
const ref = useRef<HTMLDivElement>(null)
144146

@@ -164,11 +166,21 @@ function IconContainer({
164166
style={{ scale }}
165167
onMouseEnter={() => setHovered(true)}
166168
onMouseLeave={() => setHovered(false)}
167-
className="flex items-center gap-2 px-3 py-2 rounded-xl bg-white dark:bg-slate-800 hover:bg-slate-100 dark:hover:bg-slate-700 cursor-pointer transition-colors relative"
169+
className={cn(
170+
"flex items-center gap-2 px-3 py-2 rounded-xl cursor-pointer transition-colors relative",
171+
isActive
172+
? "bg-blue-100 dark:bg-blue-900/30 border-2 border-blue-500 dark:border-blue-400"
173+
: "bg-white dark:bg-slate-800 hover:bg-slate-100 dark:hover:bg-slate-700"
174+
)}
168175
onClick={onClick}
169176
>
170177
<div className="h-5 w-5 flex-shrink-0">{icon}</div>
171-
<span className="text-sm font-medium text-slate-700 dark:text-slate-200 whitespace-nowrap">
178+
<span className={cn(
179+
"text-sm font-medium whitespace-nowrap",
180+
isActive
181+
? "text-blue-700 dark:text-blue-300 font-semibold"
182+
: "text-slate-700 dark:text-slate-200"
183+
)}>
172184
{title}
173185
</span>
174186
</motion.div>
@@ -182,10 +194,20 @@ function IconContainer({
182194
style={{ scale }}
183195
onMouseEnter={() => setHovered(true)}
184196
onMouseLeave={() => setHovered(false)}
185-
className="flex items-center gap-2 px-3 py-2 rounded-xl bg-white dark:bg-slate-800 hover:bg-slate-100 dark:hover:bg-slate-700 transition-colors relative"
197+
className={cn(
198+
"flex items-center gap-2 px-3 py-2 rounded-xl transition-colors relative",
199+
isActive
200+
? "bg-blue-100 dark:bg-blue-900/30 border-2 border-blue-500 dark:border-blue-400"
201+
: "bg-white dark:bg-slate-800 hover:bg-slate-100 dark:hover:bg-slate-700"
202+
)}
186203
>
187204
<div className="h-5 w-5 flex-shrink-0">{icon}</div>
188-
<span className="text-sm font-medium text-slate-700 dark:text-slate-200 whitespace-nowrap">
205+
<span className={cn(
206+
"text-sm font-medium whitespace-nowrap",
207+
isActive
208+
? "text-blue-700 dark:text-blue-300 font-semibold"
209+
: "text-slate-700 dark:text-slate-200"
210+
)}>
189211
{title}
190212
</span>
191213
</motion.div>

0 commit comments

Comments
 (0)