Spaces:
Running

axeronis commited on
Commit
ed7ed5e
·
1 Parent(s): cbc4965

ui: enhance demo-chat with aurora background, glassmorphism, animations and premium styling

Browse files
Files changed (1) hide show
  1. frontend/app/demo-chat/page.tsx +131 -71
frontend/app/demo-chat/page.tsx CHANGED
@@ -308,64 +308,109 @@ export default function DemoChatPage() {
308
  }
309
 
310
  return (
311
- <div className="flex flex-col h-full bg-[#0a0a0f]">
 
 
 
 
 
 
 
312
  {/* Header */}
313
- <header className="flex-shrink-0 flex items-center justify-between px-3 py-2 border-b border-white/5 bg-[#0a0a0f] safe-area-top">
314
- <div className="flex items-center gap-2">
315
- <Link href="/settings/brain" className="p-2 text-white/40 hover:text-white rounded-lg">
316
  <ArrowLeft className="w-5 h-5" />
317
  </Link>
318
- <div className="w-9 h-9 rounded-xl bg-gradient-to-br from-violet-600 to-purple-700 flex items-center justify-center">
319
- <Bot className="w-4 h-4 text-white" />
320
  </div>
321
  <div>
322
- <h1 className="font-semibold text-white text-sm">Корректировка AI</h1>
323
- <p className="text-[10px] text-white/40 hidden sm:block">Обучите AI отвечать правильно</p>
324
  </div>
325
-
326
  </div>
327
 
328
- <div className="flex items-center gap-2">
329
  {corrections.length > 0 && (
330
- <span className="px-2 py-1 bg-violet-500/20 text-violet-400 text-xs rounded-full">
 
 
 
 
331
  {corrections.length} правок
332
- </span>
333
  )}
334
- <button onClick={clearChat} className="p-2 text-white/40 hover:text-white rounded-lg">
 
 
 
 
335
  <Trash2 className="w-4 h-4" />
336
  </button>
337
  </div>
338
  </header>
339
 
 
340
  {/* Messages */}
341
- <div className="flex-1 overflow-y-auto">
342
- <div className="max-w-2xl mx-auto px-3 py-4 space-y-3">
343
  {messages.length === 0 ? (
344
- <div className="flex flex-col items-center justify-center min-h-[40vh] text-center py-8">
345
- <div className="w-14 h-14 rounded-2xl bg-gradient-to-br from-violet-600/20 to-purple-600/20 flex items-center justify-center mb-3">
346
- <Sparkles className="w-7 h-7 text-violet-400" />
347
- </div>
348
- <h3 className="text-lg font-semibold text-white mb-1">Обучите AI</h3>
349
- <p className="text-xs text-white/40 max-w-[280px] mb-5">
350
- Напишите сообщение как клиент, проверьте ответ. Если не нравится — нажмите 🪄 и опишите как исправить.
351
- </p>
 
 
 
 
 
 
 
 
352
 
 
 
 
 
 
353
 
354
- <div className="grid gap-2 w-full max-w-[280px]">
355
- <button
 
 
 
356
  onClick={() => setInput('Привет!')}
357
- className="p-2.5 bg-white/5 border border-white/5 rounded-xl text-xs text-white/70 text-left"
358
  >
359
- 💬 "Привет!"
360
- </button>
361
- <button
 
 
 
362
  onClick={() => setInput('Сколько стоит?')}
363
- className="p-2.5 bg-white/5 border border-white/5 rounded-xl text-xs text-white/70 text-left"
364
  >
365
- 💰 "Сколько стоит?"
366
- </button>
 
 
 
 
 
 
 
 
 
 
367
  </div>
368
- </div>
 
369
  ) : (
370
  messages.map((msg) => (
371
  <motion.div
@@ -373,26 +418,30 @@ export default function DemoChatPage() {
373
  initial={{ opacity: 0, y: 5 }}
374
  animate={{ opacity: 1, y: 0 }}
375
  className={cn(
376
- "flex gap-2",
377
  msg.role === 'user' && "flex-row-reverse",
378
  msg.role === 'system' && "justify-center"
379
  )}
380
  >
381
  {msg.role === 'system' ? (
382
- <div className="px-3 py-2 bg-violet-500/10 border border-violet-500/20 rounded-xl max-w-[95%]">
383
- <div className="flex items-start gap-2 text-violet-300 text-xs">
384
- <CheckCircle className="w-3.5 h-3.5 flex-shrink-0 mt-0.5" />
 
 
 
 
385
  <div className="whitespace-pre-wrap">{msg.content}</div>
386
  </div>
387
  {msg.changes && msg.changes.length > 0 && (
388
- <div className="mt-2 space-y-1 text-[10px]">
389
  {msg.changes.map((c: any, i: number) => (
390
- <div key={i} className="bg-violet-500/10 rounded-lg px-2 py-1">
391
  <div className="text-violet-200 font-medium">{c.field}</div>
392
  {(c.old || c.new) && (
393
- <div className="text-violet-300">
394
- <span className="text-red-400/70">{c.old}</span>
395
- <span className="text-violet-400 mx-1">→</span>
396
  <span className="text-green-400">{c.new}</span>
397
  </div>
398
  )}
@@ -400,29 +449,32 @@ export default function DemoChatPage() {
400
  ))}
401
  </div>
402
  )}
403
- </div>
404
  ) : (
405
  <>
406
  <div className={cn(
407
- "w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0",
408
- msg.role === 'user' ? "bg-white/10" : "bg-gradient-to-br from-violet-600 to-purple-700"
 
 
409
  )}>
410
  {msg.role === 'user' ? (
411
- <User className="w-3.5 h-3.5 text-white/70" />
412
  ) : (
413
- <Bot className="w-3.5 h-3.5 text-white" />
414
  )}
415
  </div>
416
  <div className={cn(
417
- "max-w-[80%] px-3 py-2 rounded-2xl text-sm",
418
  msg.role === 'user'
419
- ? "bg-violet-600 text-white rounded-br-md"
420
- : "bg-white/5 text-white/90 border border-white/5 rounded-bl-md"
421
  )}>
422
  <p className="whitespace-pre-wrap leading-relaxed">{msg.content}</p>
423
  </div>
424
  </>
425
  )}
 
426
  </motion.div>
427
  ))
428
  )}
@@ -519,30 +571,31 @@ export default function DemoChatPage() {
519
  )}
520
 
521
  {/* Input */}
522
-
523
- <div className="flex-shrink-0 border-t border-white/5 bg-[#0a0a0f] px-3 py-2 pb-safe">
524
  <div className="max-w-2xl mx-auto">
525
  <div className={cn(
526
- "flex items-center gap-1.5 p-1 rounded-xl transition-all",
527
  isCorrectMode
528
- ? "bg-violet-500/10 border-2 border-violet-500/30"
529
- : "bg-white/5 border border-white/10"
530
  )}>
531
- <button
 
 
532
  onClick={() => {
533
  setIsCorrectMode(!isCorrectMode)
534
  inputRef.current?.focus()
535
  }}
536
  className={cn(
537
- "p-2 rounded-lg transition-all flex-shrink-0",
538
  isCorrectMode
539
- ? "bg-violet-500 text-white"
540
- : "text-white/40 hover:text-violet-400"
541
  )}
542
  title="Режим правки"
543
  >
544
- <Wand2 className="w-4 h-4" />
545
- </button>
546
 
547
  <input
548
  ref={inputRef}
@@ -550,32 +603,39 @@ export default function DemoChatPage() {
550
  value={input}
551
  onChange={(e) => setInput(e.target.value)}
552
  onKeyPress={handleKeyPress}
553
- placeholder={isCorrectMode ? "Опиши что исправить..." : "Сообщение..."}
554
- className="flex-1 bg-transparent text-white placeholder-white/30 focus:outline-none text-sm px-1"
555
  disabled={isLoading}
556
  />
557
 
558
- <button
 
 
559
  onClick={handleSend}
560
  disabled={!input.trim() || isLoading}
561
  className={cn(
562
- "p-2 rounded-lg transition-all flex-shrink-0",
563
  input.trim()
564
- ? "bg-violet-600 hover:bg-violet-500 text-white"
565
  : "bg-white/5 text-white/20"
566
  )}
567
  >
568
- <Send className="w-4 h-4" />
569
- </button>
570
  </div>
571
 
572
  {isCorrectMode && (
573
- <p className="text-center text-[10px] text-violet-400/80 mt-1.5">
574
- 🪄 Опиши проблему: "не говори бот", "ты Анна"
575
- </p>
 
 
 
 
576
  )}
577
  </div>
578
  </div>
579
  </div>
580
  )
 
581
  }
 
308
  }
309
 
310
  return (
311
+ <div className="flex flex-col h-full bg-[#050510] relative overflow-hidden">
312
+ {/* Aurora Background */}
313
+ <div className="absolute inset-0 pointer-events-none overflow-hidden">
314
+ <div className="absolute top-1/4 left-1/4 w-96 h-96 bg-violet-600/10 rounded-full blur-3xl animate-pulse" />
315
+ <div className="absolute bottom-1/3 right-1/4 w-80 h-80 bg-purple-600/10 rounded-full blur-3xl animate-pulse" style={{ animationDelay: '1s' }} />
316
+ <div className="absolute top-2/3 left-1/2 w-64 h-64 bg-indigo-600/10 rounded-full blur-3xl animate-pulse" style={{ animationDelay: '2s' }} />
317
+ </div>
318
+
319
  {/* Header */}
320
+ <header className="relative z-10 flex-shrink-0 flex items-center justify-between px-4 py-3 border-b border-white/5 bg-[#0a0a15]/60 backdrop-blur-xl safe-area-top">
321
+ <div className="flex items-center gap-3">
322
+ <Link href="/settings/brain" className="p-2 text-white/40 hover:text-white rounded-lg transition-colors">
323
  <ArrowLeft className="w-5 h-5" />
324
  </Link>
325
+ <div className="w-10 h-10 rounded-xl bg-gradient-to-br from-violet-500 via-purple-600 to-indigo-600 flex items-center justify-center shadow-lg shadow-violet-500/20">
326
+ <Bot className="w-5 h-5 text-white" />
327
  </div>
328
  <div>
329
+ <h1 className="font-bold text-white text-base tracking-wide">Корректировка AI</h1>
330
+ <p className="text-xs text-white/50 hidden sm:block">Обучите AI отвечать правильно</p>
331
  </div>
 
332
  </div>
333
 
334
+ <div className="flex items-center gap-3">
335
  {corrections.length > 0 && (
336
+ <motion.span
337
+ initial={{ scale: 0.8, opacity: 0 }}
338
+ animate={{ scale: 1, opacity: 1 }}
339
+ className="px-3 py-1.5 bg-gradient-to-r from-violet-500/20 to-purple-500/20 text-violet-300 text-xs rounded-full border border-violet-500/20 font-medium"
340
+ >
341
  {corrections.length} правок
342
+ </motion.span>
343
  )}
344
+ <button
345
+ onClick={clearChat}
346
+ className="p-2.5 text-white/30 hover:text-red-400 hover:bg-red-500/10 rounded-xl transition-all"
347
+ title="Очистить чат"
348
+ >
349
  <Trash2 className="w-4 h-4" />
350
  </button>
351
  </div>
352
  </header>
353
 
354
+
355
  {/* Messages */}
356
+ <div className="relative z-10 flex-1 overflow-y-auto">
357
+ <div className="max-w-2xl mx-auto px-4 py-6 space-y-4">
358
  {messages.length === 0 ? (
359
+ <motion.div
360
+ initial={{ opacity: 0, y: 20 }}
361
+ animate={{ opacity: 1, y: 0 }}
362
+ transition={{ duration: 0.5 }}
363
+ className="flex flex-col items-center justify-center min-h-[50vh] text-center py-12"
364
+ >
365
+ {/* Icon */}
366
+ <motion.div
367
+ initial={{ scale: 0.8 }}
368
+ animate={{ scale: 1 }}
369
+ transition={{ type: 'spring', stiffness: 200, damping: 15 }}
370
+ className="w-20 h-20 rounded-3xl bg-gradient-to-br from-violet-500/20 via-purple-500/20 to-indigo-500/20 border border-white/5 flex items-center justify-center mb-6 relative"
371
+ >
372
+ <div className="absolute inset-0 rounded-3xl bg-gradient-to-br from-violet-500/10 to-transparent animate-pulse" />
373
+ <Sparkles className="w-9 h-9 text-violet-400 relative z-10" />
374
+ </motion.div>
375
 
376
+ {/* Title */}
377
+ <h3 className="text-2xl font-bold text-white mb-2">Обучите ваш AI</h3>
378
+ <p className="text-sm text-white/50 max-w-[320px] mb-8 leading-relaxed">
379
+ Напишите сообщение как клиент и проверьте ответ. Если не нравится — нажмите <span className="text-violet-400 font-medium">🪄</span> и опишите как исправить.
380
+ </p>
381
 
382
+ {/* Quick Actions */}
383
+ <div className="grid gap-3 w-full max-w-[340px]">
384
+ <motion.button
385
+ whileHover={{ scale: 1.02 }}
386
+ whileTap={{ scale: 0.98 }}
387
  onClick={() => setInput('Привет!')}
388
+ className="group p-4 bg-white/[0.03] hover:bg-white/[0.06] border border-white/10 hover:border-violet-500/30 rounded-2xl text-sm text-white/80 text-left transition-all duration-200 flex items-center gap-3"
389
  >
390
+ <span className="text-xl">💬</span>
391
+ <span className="group-hover:text-white transition-colors">"Привет!"</span>
392
+ </motion.button>
393
+ <motion.button
394
+ whileHover={{ scale: 1.02 }}
395
+ whileTap={{ scale: 0.98 }}
396
  onClick={() => setInput('Сколько стоит?')}
397
+ className="group p-4 bg-white/[0.03] hover:bg-white/[0.06] border border-white/10 hover:border-violet-500/30 rounded-2xl text-sm text-white/80 text-left transition-all duration-200 flex items-center gap-3"
398
  >
399
+ <span className="text-xl">💰</span>
400
+ <span className="group-hover:text-white transition-colors">"Сколько стоит?"</span>
401
+ </motion.button>
402
+ <motion.button
403
+ whileHover={{ scale: 1.02 }}
404
+ whileTap={{ scale: 0.98 }}
405
+ onClick={() => setInput('Хочу записаться')}
406
+ className="group p-4 bg-white/[0.03] hover:bg-white/[0.06] border border-white/10 hover:border-violet-500/30 rounded-2xl text-sm text-white/80 text-left transition-all duration-200 flex items-center gap-3"
407
+ >
408
+ <span className="text-xl">📅</span>
409
+ <span className="group-hover:text-white transition-colors">"Хочу записаться"</span>
410
+ </motion.button>
411
  </div>
412
+ </motion.div>
413
+
414
  ) : (
415
  messages.map((msg) => (
416
  <motion.div
 
418
  initial={{ opacity: 0, y: 5 }}
419
  animate={{ opacity: 1, y: 0 }}
420
  className={cn(
421
+ "flex gap-3",
422
  msg.role === 'user' && "flex-row-reverse",
423
  msg.role === 'system' && "justify-center"
424
  )}
425
  >
426
  {msg.role === 'system' ? (
427
+ <motion.div
428
+ initial={{ scale: 0.95 }}
429
+ animate={{ scale: 1 }}
430
+ className="px-4 py-3 bg-gradient-to-r from-violet-500/10 to-purple-500/10 border border-violet-500/20 rounded-2xl max-w-[95%] backdrop-blur-sm"
431
+ >
432
+ <div className="flex items-start gap-2 text-violet-300 text-sm">
433
+ <CheckCircle className="w-4 h-4 flex-shrink-0 mt-0.5" />
434
  <div className="whitespace-pre-wrap">{msg.content}</div>
435
  </div>
436
  {msg.changes && msg.changes.length > 0 && (
437
+ <div className="mt-3 space-y-1.5 text-xs">
438
  {msg.changes.map((c: any, i: number) => (
439
+ <div key={i} className="bg-white/5 rounded-xl px-3 py-2 border border-white/5">
440
  <div className="text-violet-200 font-medium">{c.field}</div>
441
  {(c.old || c.new) && (
442
+ <div className="text-violet-300 mt-0.5">
443
+ <span className="text-red-400/80">{c.old}</span>
444
+ <span className="text-violet-400 mx-1.5">→</span>
445
  <span className="text-green-400">{c.new}</span>
446
  </div>
447
  )}
 
449
  ))}
450
  </div>
451
  )}
452
+ </motion.div>
453
  ) : (
454
  <>
455
  <div className={cn(
456
+ "w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0 shadow-lg",
457
+ msg.role === 'user'
458
+ ? "bg-gradient-to-br from-violet-600 to-indigo-700 shadow-violet-500/20"
459
+ : "bg-gradient-to-br from-purple-600 to-violet-700 shadow-purple-500/20"
460
  )}>
461
  {msg.role === 'user' ? (
462
+ <User className="w-4 h-4 text-white" />
463
  ) : (
464
+ <Bot className="w-4 h-4 text-white" />
465
  )}
466
  </div>
467
  <div className={cn(
468
+ "max-w-[80%] px-4 py-3 rounded-2xl text-sm",
469
  msg.role === 'user'
470
+ ? "bg-gradient-to-br from-violet-600 to-indigo-600 text-white rounded-br-md shadow-lg shadow-violet-500/20"
471
+ : "bg-white/[0.05] text-white/90 border border-white/10 rounded-bl-md backdrop-blur-sm"
472
  )}>
473
  <p className="whitespace-pre-wrap leading-relaxed">{msg.content}</p>
474
  </div>
475
  </>
476
  )}
477
+
478
  </motion.div>
479
  ))
480
  )}
 
571
  )}
572
 
573
  {/* Input */}
574
+ <div className="relative z-10 flex-shrink-0 border-t border-white/5 bg-[#0a0a15]/60 backdrop-blur-xl px-4 py-3 pb-safe">
 
575
  <div className="max-w-2xl mx-auto">
576
  <div className={cn(
577
+ "flex items-center gap-2 p-1.5 rounded-2xl transition-all duration-300",
578
  isCorrectMode
579
+ ? "bg-gradient-to-r from-violet-500/10 to-purple-500/10 border-2 border-violet-500/30 shadow-lg shadow-violet-500/10"
580
+ : "bg-white/[0.05] border border-white/10"
581
  )}>
582
+ <motion.button
583
+ whileHover={{ scale: 1.05 }}
584
+ whileTap={{ scale: 0.95 }}
585
  onClick={() => {
586
  setIsCorrectMode(!isCorrectMode)
587
  inputRef.current?.focus()
588
  }}
589
  className={cn(
590
+ "p-2.5 rounded-xl transition-all flex-shrink-0",
591
  isCorrectMode
592
+ ? "bg-gradient-to-br from-violet-500 to-purple-600 text-white shadow-lg shadow-violet-500/30"
593
+ : "text-white/40 hover:text-violet-400 hover:bg-white/5"
594
  )}
595
  title="Режим правки"
596
  >
597
+ <Wand2 className="w-5 h-5" />
598
+ </motion.button>
599
 
600
  <input
601
  ref={inputRef}
 
603
  value={input}
604
  onChange={(e) => setInput(e.target.value)}
605
  onKeyPress={handleKeyPress}
606
+ placeholder={isCorrectMode ? "Опиши что исправить..." : "Напишите сообщение..."}
607
+ className="flex-1 bg-transparent text-white placeholder-white/30 focus:outline-none text-sm px-2"
608
  disabled={isLoading}
609
  />
610
 
611
+ <motion.button
612
+ whileHover={{ scale: 1.05 }}
613
+ whileTap={{ scale: 0.95 }}
614
  onClick={handleSend}
615
  disabled={!input.trim() || isLoading}
616
  className={cn(
617
+ "p-2.5 rounded-xl transition-all flex-shrink-0",
618
  input.trim()
619
+ ? "bg-gradient-to-br from-violet-600 to-indigo-600 hover:from-violet-500 hover:to-indigo-500 text-white shadow-lg shadow-violet-500/30"
620
  : "bg-white/5 text-white/20"
621
  )}
622
  >
623
+ <Send className="w-5 h-5" />
624
+ </motion.button>
625
  </div>
626
 
627
  {isCorrectMode && (
628
+ <motion.p
629
+ initial={{ opacity: 0, y: -5 }}
630
+ animate={{ opacity: 1, y: 0 }}
631
+ className="text-center text-xs text-violet-400/80 mt-2"
632
+ >
633
+ 🪄 Опишите проблему: "не говори бот", "ты Анна", "общайся на Вы"
634
+ </motion.p>
635
  )}
636
  </div>
637
  </div>
638
  </div>
639
  )
640
+
641
  }