akhaliq HF Staff commited on
Commit
9399156
·
verified ·
1 Parent(s): ae1263b

Upload components/ChatMessage.jsx with huggingface_hub

Browse files
Files changed (1) hide show
  1. components/ChatMessage.jsx +82 -0
components/ChatMessage.jsx ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ export default function ChatMessage({ message }) {
2
+ const isBot = message.sender === 'bot'
3
+
4
+ const formatTime = (date) => {
5
+ return new Date(date).toLocaleTimeString('en-US', {
6
+ hour: 'numeric',
7
+ minute: '2-digit',
8
+ hour12: true,
9
+ })
10
+ }
11
+
12
+ return (
13
+ <div
14
+ className={`flex items-start space-x-3 animate-slide-up ${
15
+ isBot ? '' : 'flex-row-reverse space-x-reverse'
16
+ }`}
17
+ >
18
+ <div
19
+ className={`flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${
20
+ isBot
21
+ ? 'bg-primary-500'
22
+ : 'bg-gradient-to-br from-purple-500 to-pink-500'
23
+ }`}
24
+ >
25
+ {isBot ? (
26
+ <svg
27
+ className="w-6 h-6 text-white"
28
+ fill="none"
29
+ stroke="currentColor"
30
+ viewBox="0 0 24 24"
31
+ >
32
+ <path
33
+ strokeLinecap="round"
34
+ strokeLinejoin="round"
35
+ strokeWidth={2}
36
+ d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"
37
+ />
38
+ </svg>
39
+ ) : (
40
+ <svg
41
+ className="w-6 h-6 text-white"
42
+ fill="none"
43
+ stroke="currentColor"
44
+ viewBox="0 0 24 24"
45
+ >
46
+ <path
47
+ strokeLinecap="round"
48
+ strokeLinejoin="round"
49
+ strokeWidth={2}
50
+ d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"
51
+ />
52
+ </svg>
53
+ )}
54
+ </div>
55
+
56
+ <div className="flex-1 max-w-[80%]">
57
+ <div
58
+ className={`rounded-2xl p-4 shadow-md ${
59
+ isBot
60
+ ? 'bg-white dark:bg-gray-800 rounded-tl-none'
61
+ : 'bg-gradient-to-br from-primary-500 to-primary-600 text-white rounded-tr-none'
62
+ }`}
63
+ >
64
+ <p
65
+ className={`text-sm md:text-base leading-relaxed ${
66
+ isBot ? 'text-gray-800 dark:text-gray-200' : 'text-white'
67
+ }`}
68
+ >
69
+ {message.text}
70
+ </p>
71
+ </div>
72
+ <p
73
+ className={`text-xs text-gray-500 dark:text-gray-400 mt-1 ${
74
+ isBot ? 'ml-2' : 'mr-2 text-right'
75
+ }`}
76
+ >
77
+ {formatTime(message.timestamp)}
78
+ </p>
79
+ </div>
80
+ </div>
81
+ )
82
+ }