Spaces:
Running

axeronis commited on
Commit
bdffd2d
·
1 Parent(s): c0e9c2b

fix(ui): portal image viewer, refine toggle, fix scroll and input gap

Browse files
frontend/components/ChatWindow.tsx CHANGED
@@ -408,11 +408,10 @@ export function ChatWindow({
408
 
409
  {/* Messages Area */}
410
  <div
411
- className="flex-1 overflow-y-auto px-4 md:px-6 space-y-6 scrollbar-thin scrollbar-thumb-white/10 overscroll-contain touch-pan-y"
412
  style={{
413
  WebkitOverflowScrolling: 'touch',
414
- willChange: 'scroll-position',
415
- transform: 'translate3d(0,0,0)' // Force GPU layer
416
  }}
417
  >
418
  {/* Top spacer to show content blurring behind header when scrolling */}
 
408
 
409
  {/* Messages Area */}
410
  <div
411
+ className="flex-1 overflow-y-auto px-4 md:px-6 space-y-6 scrollbar-thin scrollbar-thumb-white/10"
412
  style={{
413
  WebkitOverflowScrolling: 'touch',
414
+ willChange: 'transform' // Simple transform hint only
 
415
  }}
416
  >
417
  {/* Top spacer to show content blurring behind header when scrolling */}
frontend/components/ChatWindow/ChatHeader.tsx CHANGED
@@ -100,39 +100,28 @@ export function ChatHeader({
100
  )}
101
  title={isAIActive ? 'AI Активен' : 'AI Отключен'}
102
  >
103
- {/* AI Toggle Switch - FIXED UI Phase 3 */}
104
  <div className="flex items-center gap-2">
105
  <button
106
  onClick={onToggleAI}
107
  disabled={isTogglingAI}
108
  className={cn(
109
- "relative w-14 h-7 rounded-full transition-all duration-300 flex-shrink-0 border",
110
  isAIActive
111
- ? "bg-indigo-500/20 border-indigo-500/50"
112
- : "bg-slate-800/80 border-slate-700",
113
  isTogglingAI && "opacity-80"
114
  )}
115
  title={isAIActive ? 'AI Активен' : 'AI Отключен'}
116
  >
117
- {/* Track Background Active Glow */}
118
- <div className={cn(
119
- "absolute inset-0 rounded-full transition-opacity duration-300",
120
- isAIActive ? "bg-indigo-600/20 opacity-100" : "opacity-0"
121
- )} />
122
-
123
  {/* Thumb */}
124
  <motion.div
125
  animate={{
126
- x: isAIActive ? 28 : 2,
127
- scale: isTogglingAI ? 0.9 : 1,
128
  }}
129
- transition={{ type: "spring", stiffness: 500, damping: 28 }}
130
- className={cn(
131
- "absolute top-[3px] w-[20px] h-[20px] rounded-full flex items-center justify-center transition-colors duration-300 z-10 shadow-md",
132
- isAIActive
133
- ? "bg-white shadow-[0_0_10px_rgba(255,255,255,0.4)]"
134
- : "bg-slate-400"
135
- )}
136
  >
137
  {isTogglingAI && (
138
  <Loader2 className="w-3 h-3 animate-spin text-indigo-500" />
 
100
  )}
101
  title={isAIActive ? 'AI Активен' : 'AI Отключен'}
102
  >
103
+ {/* AI Toggle Switch - FIXED UI Phase 3.5 (Sleek) */}
104
  <div className="flex items-center gap-2">
105
  <button
106
  onClick={onToggleAI}
107
  disabled={isTogglingAI}
108
  className={cn(
109
+ "relative w-12 h-6 rounded-full transition-all duration-300 flex-shrink-0 border",
110
  isAIActive
111
+ ? "bg-indigo-500 border-indigo-400 shadow-[0_0_15px_rgba(99,102,241,0.3)]"
112
+ : "bg-white/10 border-white/10 hover:bg-white/20",
113
  isTogglingAI && "opacity-80"
114
  )}
115
  title={isAIActive ? 'AI Активен' : 'AI Отключен'}
116
  >
 
 
 
 
 
 
117
  {/* Thumb */}
118
  <motion.div
119
  animate={{
120
+ x: isAIActive ? 24 : 2,
121
+ scale: isTogglingAI ? 0.8 : 1,
122
  }}
123
+ transition={{ type: "spring", stiffness: 500, damping: 30 }}
124
+ className="absolute top-[3px] w-[18px] h-[18px] rounded-full bg-white shadow-sm flex items-center justify-center z-10"
 
 
 
 
 
125
  >
126
  {isTogglingAI && (
127
  <Loader2 className="w-3 h-3 animate-spin text-indigo-500" />
frontend/components/ChatWindow/MessageInput.tsx CHANGED
@@ -161,8 +161,8 @@ export function MessageInput({
161
  }
162
 
163
  return (
164
- // Added larger bottom padding (pb-24) to ensure input clears the mobile bottom nav (approx 60-80px)
165
- <div className="px-2 sm:px-3 pb-24 md:pb-6 pt-2 bg-[#050510]/60 backdrop-blur-xl border-t border-white/5 flex-shrink-0 relative z-30">
166
  <div className="max-w-4xl mx-auto relative">
167
  {/* File Preview */}
168
  {selectedFile && (
 
161
  }
162
 
163
  return (
164
+ // Adjusted padding: pb-6 (safe area) + bottom nav is distinct
165
+ <div className="px-2 sm:px-3 pb-6 md:pb-6 pt-2 bg-[#050510]/60 backdrop-blur-xl border-t border-white/5 flex-shrink-0 relative z-30">
166
  <div className="max-w-4xl mx-auto relative">
167
  {/* File Preview */}
168
  {selectedFile && (
frontend/components/ui/ImageViewer.tsx CHANGED
@@ -47,59 +47,45 @@ export function ImageViewer({ src, alt, isOpen, onClose }: ImageViewerProps) {
47
  }
48
  }
49
 
 
 
 
 
50
  return (
51
  <AnimatePresence>
52
- {isOpen && (
53
  <motion.div
54
  initial={{ opacity: 0 }}
55
  animate={{ opacity: 1 }}
56
  exit={{ opacity: 0 }}
57
  transition={{ duration: 0.2 }}
58
- className="fixed inset-0 z-[100] bg-black/95 backdrop-blur-md flex flex-col"
59
  onClick={onClose}
60
  >
61
  {/* Header Controls */}
62
  <div className="flex items-center justify-between p-4 z-50">
63
  <button
64
  onClick={(e) => { e.stopPropagation(); onClose(); }}
65
- className="p-2 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors"
66
  >
67
  <X className="w-6 h-6" />
68
  </button>
69
 
70
- <div className="flex items-center gap-4 bg-black/40 rounded-full px-4 py-2 border border-white/10 backdrop-blur-sm">
71
- <button
72
- onClick={(e) => { e.stopPropagation(); handleZoomOut(); }}
73
- className="text-white hover:text-indigo-400 disabled:opacity-50"
74
- disabled={scale <= 1}
75
- >
76
- <ZoomOut className="w-5 h-5" />
77
- </button>
78
- <span className="text-sm font-medium text-slate-300 min-w-[3ch] text-center">
79
- {Math.round(scale * 100)}%
80
- </span>
81
  <button
82
- onClick={(e) => { e.stopPropagation(); handleZoomIn(); }}
83
- className="text-white hover:text-indigo-400 disabled:opacity-50"
84
- disabled={scale >= 4}
85
  >
86
- <ZoomIn className="w-5 h-5" />
87
  </button>
88
  </div>
89
-
90
- <button
91
- onClick={(e) => { e.stopPropagation(); handleDownload(); }}
92
- className="p-2 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors"
93
- >
94
- <Download className="w-6 h-6" />
95
- </button>
96
  </div>
97
 
98
  {/* Image Container */}
99
  <div
100
- className="flex-1 overflow-hidden flex items-center justify-center relative touch-none"
101
  ref={containerRef}
102
- onClick={onClose} // Clicking background closes
103
  >
104
  <motion.div
105
  drag={scale > 1}
@@ -109,23 +95,19 @@ export function ImageViewer({ src, alt, isOpen, onClose }: ImageViewerProps) {
109
  onDragEnd={() => setIsDragging(false)}
110
  animate={{ scale, x: position.x, y: position.y }}
111
  transition={{ type: "spring", stiffness: 300, damping: 30 }}
112
- className="relative cursor-grab active:cursor-grabbing"
113
- onClick={(e) => e.stopPropagation()} // Clicking image doesn't close
114
  >
115
  <img
116
  src={src}
117
  alt={alt}
118
- className="max-w-full max-h-[85vh] object-contain rounded-md shadow-2xl"
119
  draggable={false}
120
  />
121
  </motion.div>
122
  </div>
123
-
124
- {/* Footer / Caption */}
125
- <div className="p-6 text-center z-50 pointer-events-none">
126
- <p className="text-white/80 text-sm font-medium truncate max-w-sm mx-auto">{alt}</p>
127
- </div>
128
- </motion.div>
129
  )}
130
  </AnimatePresence>
131
  )
 
47
  }
48
  }
49
 
50
+ import { createPortal } from 'react-dom'
51
+
52
+ // ... inside ImageViewer component
53
+
54
  return (
55
  <AnimatePresence>
56
+ {isOpen && createPortal(
57
  <motion.div
58
  initial={{ opacity: 0 }}
59
  animate={{ opacity: 1 }}
60
  exit={{ opacity: 0 }}
61
  transition={{ duration: 0.2 }}
62
+ className="fixed inset-0 z-[9999] bg-black/95 backdrop-blur-md flex flex-col touch-none"
63
  onClick={onClose}
64
  >
65
  {/* Header Controls */}
66
  <div className="flex items-center justify-between p-4 z-50">
67
  <button
68
  onClick={(e) => { e.stopPropagation(); onClose(); }}
69
+ className="p-3 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors backdrop-blur-md"
70
  >
71
  <X className="w-6 h-6" />
72
  </button>
73
 
74
+ {/* Simplified Controls */}
75
+ <div className="flex items-center gap-4">
 
 
 
 
 
 
 
 
 
76
  <button
77
+ onClick={(e) => { e.stopPropagation(); handleDownload(); }}
78
+ className="p-3 rounded-full bg-white/10 hover:bg-white/20 text-white transition-colors backdrop-blur-md"
 
79
  >
80
+ <Download className="w-6 h-6" />
81
  </button>
82
  </div>
 
 
 
 
 
 
 
83
  </div>
84
 
85
  {/* Image Container */}
86
  <div
87
+ className="flex-1 overflow-hidden flex items-center justify-center relative"
88
  ref={containerRef}
 
89
  >
90
  <motion.div
91
  drag={scale > 1}
 
95
  onDragEnd={() => setIsDragging(false)}
96
  animate={{ scale, x: position.x, y: position.y }}
97
  transition={{ type: "spring", stiffness: 300, damping: 30 }}
98
+ className="relative cursor-grab active:cursor-grabbing max-w-full max-h-full flex items-center justify-center"
99
+ onClick={(e) => e.stopPropagation()}
100
  >
101
  <img
102
  src={src}
103
  alt={alt}
104
+ className="max-w-[100vw] max-h-[100dvh] object-contain shadow-2xl"
105
  draggable={false}
106
  />
107
  </motion.div>
108
  </div>
109
+ </motion.div>,
110
+ document.body
 
 
 
 
111
  )}
112
  </AnimatePresence>
113
  )