Spaces:
Sleeping
Sleeping
axeronis commited on
Commit ·
1ba9153
1
Parent(s): 5792659
fix: refactor secondary nav scroll, unify glass headers, optimize chat performance
Browse files
frontend/components/ChatWindow.tsx
CHANGED
|
@@ -358,37 +358,6 @@ export function ChatWindow({
|
|
| 358 |
{/* Messages Area - pt-16 to clear sticky header, pb-4 to add some air before input */}
|
| 359 |
<div
|
| 360 |
className="flex-1 overflow-y-auto px-4 md:px-6 space-y-6 scrollbar-thin scrollbar-thumb-white/10"
|
| 361 |
-
onTouchStart={(e) => {
|
| 362 |
-
if (window.innerWidth >= 1024) return // Disable swipe for desktop
|
| 363 |
-
const startX = e.touches[0].clientX
|
| 364 |
-
const startY = e.touches[0].clientY
|
| 365 |
-
|
| 366 |
-
const handleTouchMove = (moveEvent: TouchEvent) => {
|
| 367 |
-
const moveX = moveEvent.touches[0].clientX
|
| 368 |
-
const moveY = moveEvent.touches[0].clientY
|
| 369 |
-
|
| 370 |
-
const diffX = startX - moveX
|
| 371 |
-
const diffY = Math.abs(startY - moveY)
|
| 372 |
-
|
| 373 |
-
// Prioritize horizontal movement (multiply X diff for tolerance)
|
| 374 |
-
// This allows diagonal swipes to count as horizontal if they have enough momentum
|
| 375 |
-
if (Math.abs(diffX) > diffY * 0.8) {
|
| 376 |
-
if (Math.abs(diffX) > 10) { // If horizontal movement is detected, stop page bounce
|
| 377 |
-
if (moveEvent.cancelable) moveEvent.preventDefault()
|
| 378 |
-
}
|
| 379 |
-
|
| 380 |
-
if (diffX > 40) { // Swipe left (open)
|
| 381 |
-
setIsMobileDrawerOpen(true)
|
| 382 |
-
document.removeEventListener('touchmove', handleTouchMove)
|
| 383 |
-
}
|
| 384 |
-
}
|
| 385 |
-
}
|
| 386 |
-
|
| 387 |
-
document.addEventListener('touchmove', handleTouchMove)
|
| 388 |
-
document.addEventListener('touchend', () => {
|
| 389 |
-
document.removeEventListener('touchmove', handleTouchMove)
|
| 390 |
-
}, { once: true })
|
| 391 |
-
}}
|
| 392 |
>
|
| 393 |
{/* Top spacer to show content blurring behind header when scrolling */}
|
| 394 |
<div className="h-4 shrink-0" />
|
|
|
|
| 358 |
{/* Messages Area - pt-16 to clear sticky header, pb-4 to add some air before input */}
|
| 359 |
<div
|
| 360 |
className="flex-1 overflow-y-auto px-4 md:px-6 space-y-6 scrollbar-thin scrollbar-thumb-white/10"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 361 |
>
|
| 362 |
{/* Top spacer to show content blurring behind header when scrolling */}
|
| 363 |
<div className="h-4 shrink-0" />
|
frontend/components/ChatWindow/ChatHeader.tsx
CHANGED
|
@@ -33,8 +33,20 @@ export function ChatHeader({
|
|
| 33 |
onTrainAI,
|
| 34 |
}: ChatHeaderProps) {
|
| 35 |
return (
|
| 36 |
-
<div className="
|
| 37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
{/* Desktop Toggle */}
|
| 39 |
<button
|
| 40 |
onClick={onToggleLeadsList}
|
|
@@ -44,10 +56,6 @@ export function ChatHeader({
|
|
| 44 |
{isLeadsListOpen ? <ArrowLeft className="w-5 h-5" /> : <MoreVertical className="w-5 h-5 rotate-90" />}
|
| 45 |
</button>
|
| 46 |
|
| 47 |
-
<button onClick={onBack} className="lg:hidden p-2 -ml-2 text-slate-400 hover:text-white">
|
| 48 |
-
<ArrowLeft className="w-5 h-5" />
|
| 49 |
-
</button>
|
| 50 |
-
|
| 51 |
<div className="flex items-center gap-3">
|
| 52 |
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-600/30 to-purple-600/30 flex items-center justify-center text-indigo-400 font-bold text-sm border border-indigo-500/30 relative shadow-sm">
|
| 53 |
{lead?.name?.charAt(0) || 'L'}
|
|
@@ -140,6 +148,6 @@ export function ChatHeader({
|
|
| 140 |
<Brain className="w-5 h-5" />
|
| 141 |
</button>
|
| 142 |
</div>
|
| 143 |
-
</div>
|
| 144 |
)
|
| 145 |
}
|
|
|
|
| 33 |
onTrainAI,
|
| 34 |
}: ChatHeaderProps) {
|
| 35 |
return (
|
| 36 |
+
<div className="h-16 shrink-0 flex items-center justify-between px-4 md:px-6 relative z-20 border-b border-white/5 bg-[#0D0E18]/50 backdrop-blur-xl backdrop-saturate-[1.8]">
|
| 37 |
+
{/* Aurora Background Atmosphere - Synced */}
|
| 38 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 bg-gradient-to-r from-indigo-500/5 to-purple-500/5 opacity-50" />
|
| 39 |
+
|
| 40 |
+
{/* Left: Lead Info */}
|
| 41 |
+
<div className="flex items-center gap-3 overflow-hidden">
|
| 42 |
+
{/* Back Button (Mobile/Tablet only) */}
|
| 43 |
+
<button
|
| 44 |
+
onClick={onBack}
|
| 45 |
+
className="lg:hidden p-2 -ml-2 text-slate-400 hover:text-white hover:bg-white/10 rounded-full transition-colors"
|
| 46 |
+
>
|
| 47 |
+
<ArrowLeft className="w-5 h-5" />
|
| 48 |
+
</button>
|
| 49 |
+
|
| 50 |
{/* Desktop Toggle */}
|
| 51 |
<button
|
| 52 |
onClick={onToggleLeadsList}
|
|
|
|
| 56 |
{isLeadsListOpen ? <ArrowLeft className="w-5 h-5" /> : <MoreVertical className="w-5 h-5 rotate-90" />}
|
| 57 |
</button>
|
| 58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
<div className="flex items-center gap-3">
|
| 60 |
<div className="w-10 h-10 rounded-full bg-gradient-to-br from-indigo-600/30 to-purple-600/30 flex items-center justify-center text-indigo-400 font-bold text-sm border border-indigo-500/30 relative shadow-sm">
|
| 61 |
{lead?.name?.charAt(0) || 'L'}
|
|
|
|
| 148 |
<Brain className="w-5 h-5" />
|
| 149 |
</button>
|
| 150 |
</div>
|
| 151 |
+
</div >
|
| 152 |
)
|
| 153 |
}
|
frontend/components/Header.tsx
CHANGED
|
@@ -57,12 +57,9 @@ export function Header() {
|
|
| 57 |
}
|
| 58 |
|
| 59 |
return (
|
| 60 |
-
<header className="hidden md:flex h-16 border-b border-white/
|
| 61 |
{/* Background Atmosphere - Subtly blooming behind the glass */}
|
| 62 |
-
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10">
|
| 63 |
-
<div className="absolute top-[-100%] right-[-10%] w-[50%] h-[300%] bg-cyan-500/10 blur-[100px] rounded-full rotate-12" />
|
| 64 |
-
<div className="absolute top-[-100%] left-[-10%] w-[40%] h-[300%] bg-indigo-500/10 blur-[100px] rounded-full -rotate-12" />
|
| 65 |
-
</div>
|
| 66 |
|
| 67 |
<div className="relative z-10 flex items-center justify-between w-full">
|
| 68 |
{/* Left: Logo (Visible only when sidebar is hidden i.e. < lg) */}
|
|
|
|
| 57 |
}
|
| 58 |
|
| 59 |
return (
|
| 60 |
+
<header className="hidden md:flex h-16 border-b border-white/5 md:border-b-0 lg:border-b lg:border-white/5 bg-[#0D0E18]/50 backdrop-blur-xl backdrop-saturate-[1.8] items-center justify-between px-6 sticky top-0 z-30 overflow-hidden">
|
| 61 |
{/* Background Atmosphere - Subtly blooming behind the glass */}
|
| 62 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 bg-gradient-to-b from-white/5 to-transparent opacity-50" />
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
<div className="relative z-10 flex items-center justify-between w-full">
|
| 65 |
{/* Left: Logo (Visible only when sidebar is hidden i.e. < lg) */}
|
frontend/components/SecondaryNav.tsx
CHANGED
|
@@ -42,11 +42,6 @@ export function SecondaryNav() {
|
|
| 42 |
const { t } = useTranslation()
|
| 43 |
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
| 44 |
|
| 45 |
-
// Drag to scroll state
|
| 46 |
-
const [isDragging, setIsDragging] = useState(false)
|
| 47 |
-
const [startX, setStartX] = useState(0)
|
| 48 |
-
const [scrollLeft, setScrollLeft] = useState(0)
|
| 49 |
-
|
| 50 |
const isOwner = user?.role === 'OWNER' || user?.role === 'admin' || user?.is_superuser
|
| 51 |
const visibleItems = navItems.filter(item => isOwner || !item.ownerOnly)
|
| 52 |
|
|
@@ -57,108 +52,31 @@ export function SecondaryNav() {
|
|
| 57 |
if (scrollContainerRef.current) {
|
| 58 |
const activeItem = scrollContainerRef.current.querySelector('[data-active="true"]')
|
| 59 |
if (activeItem) {
|
| 60 |
-
// Use smooth behavior for programmatic scroll (initial load/click)
|
| 61 |
activeItem.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' })
|
| 62 |
}
|
| 63 |
}
|
| 64 |
}, [pathname])
|
| 65 |
|
| 66 |
-
// Handle mouse wheel for horizontal scroll
|
| 67 |
-
const handleWheel = (e: React.WheelEvent) => {
|
| 68 |
-
if (scrollContainerRef.current) {
|
| 69 |
-
if (e.deltaY !== 0) {
|
| 70 |
-
scrollContainerRef.current.style.scrollBehavior = 'auto'
|
| 71 |
-
scrollContainerRef.current.scrollLeft += e.deltaY * 0.5
|
| 72 |
-
}
|
| 73 |
-
}
|
| 74 |
-
}
|
| 75 |
-
|
| 76 |
-
// Drag handlers
|
| 77 |
-
const handleMouseDown = (e: React.MouseEvent) => {
|
| 78 |
-
if (!scrollContainerRef.current) return
|
| 79 |
-
setIsDragging(true)
|
| 80 |
-
setStartX(e.pageX - scrollContainerRef.current.offsetLeft)
|
| 81 |
-
setScrollLeft(scrollContainerRef.current.scrollLeft)
|
| 82 |
-
// Set body cursor to prevent flickering
|
| 83 |
-
document.body.style.cursor = 'grabbing'
|
| 84 |
-
document.body.style.userSelect = 'none'
|
| 85 |
-
scrollContainerRef.current.style.scrollBehavior = 'auto'
|
| 86 |
-
}
|
| 87 |
-
|
| 88 |
-
// Attach window listeners for drag
|
| 89 |
-
useEffect(() => {
|
| 90 |
-
const handleWindowMouseMove = (e: MouseEvent) => {
|
| 91 |
-
if (!isDragging || !scrollContainerRef.current) return
|
| 92 |
-
e.preventDefault()
|
| 93 |
-
const x = e.pageX - scrollContainerRef.current.offsetLeft
|
| 94 |
-
const walk = (x - startX) * 1.5
|
| 95 |
-
scrollContainerRef.current.scrollLeft = scrollLeft - walk
|
| 96 |
-
}
|
| 97 |
-
|
| 98 |
-
const handleWindowMouseUp = () => {
|
| 99 |
-
if (isDragging) {
|
| 100 |
-
setIsDragging(false)
|
| 101 |
-
document.body.style.cursor = ''
|
| 102 |
-
document.body.style.userSelect = ''
|
| 103 |
-
if (scrollContainerRef.current) scrollContainerRef.current.style.cursor = 'grab'
|
| 104 |
-
}
|
| 105 |
-
}
|
| 106 |
-
|
| 107 |
-
if (isDragging) {
|
| 108 |
-
window.addEventListener('mousemove', handleWindowMouseMove)
|
| 109 |
-
window.addEventListener('mouseup', handleWindowMouseUp)
|
| 110 |
-
}
|
| 111 |
-
|
| 112 |
-
return () => {
|
| 113 |
-
window.removeEventListener('mousemove', handleWindowMouseMove)
|
| 114 |
-
window.removeEventListener('mouseup', handleWindowMouseUp)
|
| 115 |
-
if (isDragging) {
|
| 116 |
-
document.body.style.cursor = ''
|
| 117 |
-
document.body.style.userSelect = ''
|
| 118 |
-
}
|
| 119 |
-
}
|
| 120 |
-
}, [isDragging, startX, scrollLeft])
|
| 121 |
-
|
| 122 |
return (
|
| 123 |
-
<div className="hidden md:flex lg:hidden w-full h-14 bg-[#0D0E18]/
|
| 124 |
-
{/* Aurora Background Atmosphere
|
| 125 |
-
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10">
|
| 126 |
-
<div className="absolute bottom-[-100%] right-[-5%] w-[40%] h-[300%] bg-cyan-500/10 blur-[100px] rounded-full" />
|
| 127 |
-
<div className="absolute bottom-[-100%] left-[-5%] w-[35%] h-[300%] bg-indigo-500/10 blur-[100px] rounded-full" />
|
| 128 |
-
</div>
|
| 129 |
|
| 130 |
-
{/*
|
| 131 |
<style jsx>{`
|
| 132 |
.aurora-scroll::-webkit-scrollbar {
|
| 133 |
-
height:
|
| 134 |
-
background: transparent;
|
| 135 |
-
}
|
| 136 |
-
.aurora-scroll::-webkit-scrollbar-track {
|
| 137 |
background: transparent;
|
| 138 |
}
|
| 139 |
-
.aurora-scroll::-webkit-scrollbar-thumb {
|
| 140 |
-
background: linear-gradient(90deg, #22d3ee, #10b981);
|
| 141 |
-
border-radius: 99px;
|
| 142 |
-
/* Laser Glow Effect */
|
| 143 |
-
filter: drop-shadow(0 0 8px rgba(34, 211, 238, 0.8));
|
| 144 |
-
}
|
| 145 |
-
.aurora-scroll::-webkit-scrollbar-thumb:hover {
|
| 146 |
-
filter: drop-shadow(0 0 12px rgba(34, 211, 238, 1));
|
| 147 |
-
}
|
| 148 |
.aurora-scroll {
|
| 149 |
-
scrollbar-width:
|
| 150 |
-
|
| 151 |
}
|
| 152 |
`}</style>
|
| 153 |
|
| 154 |
<div
|
| 155 |
ref={scrollContainerRef}
|
| 156 |
-
|
| 157 |
-
onMouseDown={handleMouseDown}
|
| 158 |
-
className={cn(
|
| 159 |
-
"relative z-10 flex items-center gap-1 px-4 overflow-x-auto w-full aurora-scroll select-none",
|
| 160 |
-
isDragging ? "cursor-grabbing" : "cursor-default"
|
| 161 |
-
)}
|
| 162 |
style={{
|
| 163 |
WebkitOverflowScrolling: 'touch'
|
| 164 |
}}
|
|
@@ -174,8 +92,7 @@ export function SecondaryNav() {
|
|
| 174 |
data-active={active}
|
| 175 |
draggable={false}
|
| 176 |
className={cn(
|
| 177 |
-
"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-300 shrink-0
|
| 178 |
-
isDragging && "pointer-events-none",
|
| 179 |
active
|
| 180 |
? "text-indigo-400 bg-white/5 border border-white/10 shadow-[0_0_20px_rgba(99,102,241,0.1)]"
|
| 181 |
: "text-slate-400 hover:text-white hover:bg-white/5"
|
|
|
|
| 42 |
const { t } = useTranslation()
|
| 43 |
const scrollContainerRef = useRef<HTMLDivElement>(null)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
const isOwner = user?.role === 'OWNER' || user?.role === 'admin' || user?.is_superuser
|
| 46 |
const visibleItems = navItems.filter(item => isOwner || !item.ownerOnly)
|
| 47 |
|
|
|
|
| 52 |
if (scrollContainerRef.current) {
|
| 53 |
const activeItem = scrollContainerRef.current.querySelector('[data-active="true"]')
|
| 54 |
if (activeItem) {
|
|
|
|
| 55 |
activeItem.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' })
|
| 56 |
}
|
| 57 |
}
|
| 58 |
}, [pathname])
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
return (
|
| 61 |
+
<div className="hidden md:flex lg:hidden w-full h-14 bg-[#0D0E18]/50 backdrop-blur-xl border-b border-white/5 sticky top-16 z-20 overflow-hidden shadow-lg">
|
| 62 |
+
{/* Aurora Background Atmosphere */}
|
| 63 |
+
<div className="absolute inset-0 pointer-events-none overflow-hidden -z-10 bg-gradient-to-r from-indigo-500/5 to-purple-500/5 opacity-50" />
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
{/* Scrollbar Styles */}
|
| 66 |
<style jsx>{`
|
| 67 |
.aurora-scroll::-webkit-scrollbar {
|
| 68 |
+
height: 0px;
|
|
|
|
|
|
|
|
|
|
| 69 |
background: transparent;
|
| 70 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 71 |
.aurora-scroll {
|
| 72 |
+
scrollbar-width: none;
|
| 73 |
+
-ms-overflow-style: none;
|
| 74 |
}
|
| 75 |
`}</style>
|
| 76 |
|
| 77 |
<div
|
| 78 |
ref={scrollContainerRef}
|
| 79 |
+
className="relative z-10 flex items-center gap-1 px-4 overflow-x-auto w-full aurora-scroll select-none"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
style={{
|
| 81 |
WebkitOverflowScrolling: 'touch'
|
| 82 |
}}
|
|
|
|
| 92 |
data-active={active}
|
| 93 |
draggable={false}
|
| 94 |
className={cn(
|
| 95 |
+
"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium whitespace-nowrap transition-all duration-300 shrink-0 select-none",
|
|
|
|
| 96 |
active
|
| 97 |
? "text-indigo-400 bg-white/5 border border-white/10 shadow-[0_0_20px_rgba(99,102,241,0.1)]"
|
| 98 |
: "text-slate-400 hover:text-white hover:bg-white/5"
|