phase 3 bug fixing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { useState } from 'react'
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { NavLink, Link } from 'react-router-dom'
|
||||
import { cn } from '../../lib/utils'
|
||||
import { useAuth } from '../../contexts/AuthContext'
|
||||
|
||||
type SidebarState = 'expanded' | 'collapsed' | 'hidden'
|
||||
|
||||
@@ -64,6 +65,7 @@ interface SidebarProps {
|
||||
|
||||
export function Sidebar({ className }: SidebarProps) {
|
||||
const [state, setState] = useState<SidebarState>('expanded')
|
||||
const { user, isAuthenticated } = useAuth()
|
||||
|
||||
const isCollapsed = state === 'collapsed'
|
||||
const width = isCollapsed ? 'w-14' : 'w-80'
|
||||
@@ -133,8 +135,37 @@ export function Sidebar({ className }: SidebarProps) {
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
{/* Bottom: settings */}
|
||||
<div className="py-2 px-2 border-t border-white/10 shrink-0">
|
||||
{/* Bottom: user + settings */}
|
||||
<div className="py-2 px-2 border-t border-white/10 shrink-0 flex flex-col gap-0.5">
|
||||
{isAuthenticated ? (
|
||||
<NavLink
|
||||
to="/settings"
|
||||
className={({ isActive }) =>
|
||||
cn(
|
||||
'flex items-center gap-3 rounded px-2 min-h-[44px] transition-colors',
|
||||
isActive ? 'bg-white/20 text-white' : 'text-white/70 hover:bg-white/10 hover:text-white',
|
||||
)
|
||||
}
|
||||
title={isCollapsed ? user?.username : undefined}
|
||||
>
|
||||
<div className="w-5 h-5 rounded-full bg-[#0052CC] flex items-center justify-center text-[10px] font-bold shrink-0">
|
||||
{user?.username?.[0]?.toUpperCase()}
|
||||
</div>
|
||||
{!isCollapsed && <span className="text-sm font-medium truncate">{user?.username}</span>}
|
||||
</NavLink>
|
||||
) : (
|
||||
<Link
|
||||
to="/login"
|
||||
className="flex items-center gap-3 rounded px-2 min-h-[44px] text-white/70 hover:bg-white/10 hover:text-white transition-colors"
|
||||
title={isCollapsed ? 'Sign in' : undefined}
|
||||
>
|
||||
<svg width="20" height="20" fill="none" stroke="currentColor" strokeWidth="1.5" viewBox="0 0 24 24" aria-hidden="true">
|
||||
<path strokeLinecap="round" strokeLinejoin="round" d="M15.75 9V5.25A2.25 2.25 0 0 0 13.5 3h-6a2.25 2.25 0 0 0-2.25 2.25v13.5A2.25 2.25 0 0 0 7.5 21h6a2.25 2.25 0 0 0 2.25-2.25V15M12 9l-3 3m0 0 3 3m-3-3h12.75" />
|
||||
</svg>
|
||||
{!isCollapsed && <span className="text-sm font-medium">Sign in</span>}
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<NavLink
|
||||
to="/settings"
|
||||
className={({ isActive }) =>
|
||||
|
||||
Reference in New Issue
Block a user