Martechsol commited on
Commit
e53daf8
·
1 Parent(s): cc9fda7

Reverted UI changes to restore original alignment and icon sizing

Browse files
Files changed (1) hide show
  1. static/addon.html +156 -159
static/addon.html CHANGED
@@ -4,238 +4,226 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Martechsol Assistant Widget</title>
 
7
  /* Premium Design for Martechsol Assistant */
8
- @import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&display=swap');
9
-
10
- :root {
11
- --primary-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
12
- --bot-bg: #ffffff;
13
- --user-bg: #1e293b;
14
- --glass-bg: rgba(255, 255, 255, 0.95);
15
- --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
16
- --shadow-lg: 0 15px 35px rgba(0,0,0,0.12);
17
- --radius: 20px;
18
- }
19
 
20
  #martech-chat-wrapper {
21
- all: initial; /* Reset to prevent theme leaks */
22
- font-family: 'Outfit', sans-serif;
23
- position: fixed;
24
- z-index: 999999;
25
- bottom: 0;
26
- right: 0;
27
- }
28
-
29
- #martech-chat-wrapper * {
30
- box-sizing: border-box;
31
  }
32
 
33
  /* Floating Action Button (FAB) */
34
  #martech-chat-fab {
35
  position: fixed;
36
- right: 20px;
37
- bottom: 20px;
38
- width: 70px;
39
- height: 70px;
40
  background: transparent;
 
41
  display: flex;
42
  align-items: center;
43
  justify-content: center;
44
  cursor: pointer;
45
- z-index: 1000000;
46
- transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
47
- }
48
-
49
- #chat-icon {
50
- width: 100%;
51
- height: 100%;
52
- display: flex;
53
- align-items: center;
54
- justify-content: center;
55
- }
56
-
57
- dotlottie-player {
58
- width: 120% !important; /* Slightly larger to fill space */
59
- height: 120% !important;
60
  }
61
 
62
  #martech-chat-fab:hover {
63
  transform: scale(1.1);
64
  }
65
 
 
 
 
 
 
 
66
  /* Chat Window Styling */
67
  #martech-chat-box {
68
  position: fixed;
69
  right: 25px;
70
  bottom: 100px;
71
  width: 400px;
72
- height: 600px;
73
- background: var(--glass-bg);
74
- backdrop-filter: blur(15px);
75
- -webkit-backdrop-filter: blur(15px);
76
- border-radius: var(--radius);
77
  overflow: hidden;
78
  display: none;
79
  flex-direction: column;
80
- box-shadow: var(--shadow-lg);
81
- z-index: 999999;
82
- border: 1px solid rgba(226, 232, 240, 0.8);
83
  opacity: 0;
84
- transform: translateY(30px) scale(0.95);
85
- transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
86
  }
87
 
88
  #martech-chat-box.is-visible {
89
  display: flex;
90
  opacity: 1;
91
- transform: translateY(0) scale(1);
92
  }
93
 
94
  #martech-chat-header {
95
  background: #ffffff;
96
- padding: 20px 24px;
97
  border-bottom: 1px solid #f1f5f9;
98
  display: flex;
99
  align-items: center;
100
- justify-content: space-between;
101
  }
102
 
103
- .header-info {
104
- display: flex;
105
- align-items: center;
106
- gap: 12px;
107
  }
108
 
109
  #martech-chat-header .dot {
110
- width: 8px;
111
- height: 8px;
112
  background: #10b981;
113
  border-radius: 50%;
114
- box-shadow: 0 0 10px #10b981;
115
  }
116
 
117
  #martech-chat-header span {
118
  font-weight: 600;
119
- color: #0f172a;
120
- font-size: 16px;
121
- letter-spacing: -0.01em;
122
  }
123
 
124
- /* Chat Area Styling */
125
  #chat-messages {
126
  flex: 1;
127
  overflow-y: auto;
128
- padding: 24px;
129
  display: flex;
130
  flex-direction: column;
131
- gap: 16px;
132
- background: #fdfdfd;
133
  scroll-behavior: smooth;
134
  }
135
 
136
- /* Custom Scrollbar */
137
- #chat-messages::-webkit-scrollbar { width: 5px; }
138
- #chat-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 10px; }
 
139
 
140
  .chat-message {
141
  max-width: 85%;
142
- padding: 14px 18px;
143
- border-radius: 18px;
144
- font-size: 14.5px;
145
- line-height: 1.6;
146
- position: relative;
147
- animation: messageIn 0.3s ease-out forwards;
148
- box-shadow: var(--shadow-sm);
149
- }
150
-
151
- @keyframes messageIn {
152
- from { opacity: 0; transform: translateY(10px) scale(0.98); }
153
- to { opacity: 1; transform: translateY(0) scale(1); }
154
  }
155
 
156
  .chat-message.user {
157
  align-self: flex-end;
158
- background: var(--user-bg);
159
  color: white;
160
  border-bottom-right-radius: 4px;
161
  }
162
 
163
  .chat-message.bot {
164
  align-self: flex-start;
165
- background: var(--bot-bg);
166
  color: #334155;
167
  border-bottom-left-radius: 4px;
168
- border: 1px solid #f1f5f9;
 
169
  }
170
 
171
- /* HTML/Markdown rendering polish */
172
- .chat-message b { font-weight: 600; color: #0f172a; }
173
- .chat-message.user b { color: #ffffff; }
174
-
175
- .chat-message ul, .chat-message ol { margin: 8px 0; padding-left: 20px; }
176
- .chat-message li { margin-bottom: 4px; }
177
-
178
  #chat-input-area {
179
- padding: 20px 24px;
180
  background: #ffffff;
181
  border-top: 1px solid #f1f5f9;
182
  display: flex;
183
- gap: 12px;
184
  align-items: center;
185
  }
186
 
187
  #chat-input {
188
  flex: 1;
189
  border: 1px solid #e2e8f0;
190
- border-radius: 24px;
191
- padding: 12px 20px;
192
  font-size: 14px;
193
  outline: none;
194
- transition: all 0.2s;
195
- background: #f8fafc;
 
196
  }
197
 
198
  #chat-input:focus {
199
  border-color: #10b981;
200
- background: #ffffff;
201
- box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
 
 
 
202
  }
203
 
204
  #chat-send {
205
- background: var(--primary-gradient);
206
  color: white;
207
  border: none;
208
- width: 46px;
209
- height: 46px;
210
  border-radius: 50%;
211
  display: flex;
212
  align-items: center;
213
  justify-content: center;
214
  cursor: pointer;
215
- transition: all 0.3s;
216
- box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
 
 
 
217
  }
218
 
219
- #chat-send:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4); }
220
- #chat-send:active { transform: translateY(0); }
 
 
 
 
 
 
 
221
 
222
- /* Typing Indicator */
223
- .typing-indicator { display: flex; gap: 5px; padding: 6px 0; }
 
 
 
 
 
 
224
  .typing-indicator span {
225
- width: 6px; height: 6px; background: #cbd5e1; border-radius: 50%;
 
 
 
226
  animation: typing-dots 1.4s infinite ease-in-out both;
227
  }
228
- .typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
229
- .typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
230
  @keyframes typing-dots {
231
- 0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
232
- 40% { transform: scale(1.1); opacity: 1; }
233
  }
234
 
235
  @media (max-width: 480px) {
236
  #martech-chat-box {
237
- right: 0; bottom: 0; width: 100%; height: 100%;
238
- border-radius: 0;
 
 
239
  }
240
  }
241
  </style>
@@ -248,10 +236,10 @@
248
  <div id="martech-chat-wrapper">
249
  <div id="martech-chat-fab">
250
  <!-- Animated Chatbot Icon -->
251
- <div id="chat-icon">
252
  <dotlottie-player
253
  src="https://joedown11-chatrag.hf.space/static/bot-icon.lottie"
254
- background="transparent" speed="1" style="width: 100%; height: 100%;" loop autoplay>
255
  </dotlottie-player>
256
  </div>
257
  <!-- Close Icon -->
@@ -326,34 +314,10 @@
326
  localStorage.setItem('martech_session_id', sessionId);
327
  }
328
 
329
- function formatMessage(text) {
330
- if (!text) return "";
331
- // 1. Convert Markdown Bold to HTML Bold (safety)
332
- let formatted = text.replace(/\*\*(.*?)\*\*/g, '<b>$1</b>');
333
- // 2. Handle Bullet points (must be at start of line)
334
- const lines = formatted.split('\n');
335
- let inList = false;
336
- let result = [];
337
-
338
- lines.forEach(line => {
339
- const trimmed = line.trim();
340
- if (trimmed.startsWith('* ') || trimmed.startsWith('• ')) {
341
- if (!inList) { result.push('<ul>'); inList = true; }
342
- result.push(`<li>${trimmed.substring(2)}</li>`);
343
- } else {
344
- if (inList) { result.push('</ul>'); inList = false; }
345
- result.push(line);
346
- }
347
- });
348
- if (inList) result.push('</ul>');
349
-
350
- return result.join('\n').replace(/\n/g, '<br>');
351
- }
352
-
353
  function appendMessage(role, content) {
354
  const div = document.createElement('div');
355
  div.className = `chat-message ${role}`;
356
- div.innerHTML = formatMessage(content);
357
  messagesContainer.appendChild(div);
358
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
359
  return div;
@@ -455,7 +419,7 @@
455
  'u': 'yihj', 'v': 'cfgb', 'w': 'qase', 'x': 'zsdc', 'y': 'tghu',
456
  'z': 'xas',
457
  };
458
- const TYPO_CHANCE = 0.05;
459
 
460
  function getNearbyChar(ch) {
461
  const lower = ch.toLowerCase();
@@ -471,26 +435,59 @@
471
  const sleep = ms => new Promise(r => setTimeout(r, ms));
472
 
473
  async function typeMessageWithTypos(element, text) {
474
- const fullHtml = formatMessage(text);
475
-
476
- // Simple HTML-aware typing: split by tags
477
- const tokens = fullHtml.split(/(<[^>]*>)/);
478
- let currentHtml = "";
479
 
480
- for (const token of tokens) {
481
- if (token.startsWith("<")) {
482
- // Instantly add tags
483
- currentHtml += token;
484
- element.innerHTML = currentHtml;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
  } else {
486
- // Type text content char by char
487
- for (let char of token) {
488
- currentHtml += char;
489
- element.innerHTML = currentHtml;
490
- await sleep(Math.random() * 20 + 10);
491
  }
492
  }
 
493
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
 
 
 
 
 
 
 
494
  }
495
  }
496
 
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Martechsol Assistant Widget</title>
7
+ <style>
8
  /* Premium Design for Martechsol Assistant */
9
+ @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
 
 
 
 
 
 
 
 
 
 
10
 
11
  #martech-chat-wrapper {
12
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
  /* Floating Action Button (FAB) */
16
  #martech-chat-fab {
17
  position: fixed;
18
+ right: 10px;
19
+ bottom: 25px;
20
+ width: auto;
21
+ height: auto;
22
  background: transparent;
23
+ border-radius: 50%;
24
  display: flex;
25
  align-items: center;
26
  justify-content: center;
27
  cursor: pointer;
28
+ z-index: 999999;
29
+ transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease, box-shadow 0.3s ease;
30
+ -webkit-tap-highlight-color: transparent;
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  #martech-chat-fab:hover {
34
  transform: scale(1.1);
35
  }
36
 
37
+ #martech-chat-fab.is-active {
38
+ background: #1e293b;
39
+ box-shadow: 0 10px 25px rgba(30, 41, 59, 0.4);
40
+ transform: scale(0.8);
41
+ }
42
+
43
  /* Chat Window Styling */
44
  #martech-chat-box {
45
  position: fixed;
46
  right: 25px;
47
  bottom: 100px;
48
  width: 400px;
49
+ height: 550px;
50
+ background: #ffffff;
51
+ border-radius: 16px;
 
 
52
  overflow: hidden;
53
  display: none;
54
  flex-direction: column;
55
+ box-shadow: 0 12px 50px rgba(0, 0, 0, 0.2);
56
+ z-index: 999998;
57
+ border: 1px solid #e2e8f0;
58
  opacity: 0;
59
+ transform: translateY(20px);
60
+ transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
61
  }
62
 
63
  #martech-chat-box.is-visible {
64
  display: flex;
65
  opacity: 1;
66
+ transform: translateY(0);
67
  }
68
 
69
  #martech-chat-header {
70
  background: #ffffff;
71
+ padding: 16px 20px;
72
  border-bottom: 1px solid #f1f5f9;
73
  display: flex;
74
  align-items: center;
75
+ gap: 12px;
76
  }
77
 
78
+ @keyframes pulse-dot {
79
+ 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
80
+ 70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
81
+ 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
82
  }
83
 
84
  #martech-chat-header .dot {
85
+ width: 10px;
86
+ height: 10px;
87
  background: #10b981;
88
  border-radius: 50%;
89
+ animation: pulse-dot 2s infinite;
90
  }
91
 
92
  #martech-chat-header span {
93
  font-weight: 600;
94
+ color: #1e293b;
95
+ font-size: 15px;
 
96
  }
97
 
98
+ /* Custom Chat Area Styling */
99
  #chat-messages {
100
  flex: 1;
101
  overflow-y: auto;
102
+ padding: 16px;
103
  display: flex;
104
  flex-direction: column;
105
+ gap: 12px;
106
+ background: #f8fafc;
107
  scroll-behavior: smooth;
108
  }
109
 
110
+ /* Custom Scrollbar for messages */
111
+ #chat-messages::-webkit-scrollbar { width: 6px; }
112
+ #chat-messages::-webkit-scrollbar-track { background: transparent; }
113
+ #chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
114
 
115
  .chat-message {
116
  max-width: 85%;
117
+ padding: 12px 16px;
118
+ border-radius: 16px;
119
+ font-size: 14px;
120
+ line-height: 1.5;
121
+ word-wrap: break-word;
122
+ white-space: pre-wrap;
 
 
 
 
 
 
123
  }
124
 
125
  .chat-message.user {
126
  align-self: flex-end;
127
+ background: #1e293b;
128
  color: white;
129
  border-bottom-right-radius: 4px;
130
  }
131
 
132
  .chat-message.bot {
133
  align-self: flex-start;
134
+ background: #ffffff;
135
  color: #334155;
136
  border-bottom-left-radius: 4px;
137
+ border: 1px solid #e2e8f0;
138
+ box-shadow: 0 2px 4px rgba(0,0,0,0.02);
139
  }
140
 
 
 
 
 
 
 
 
141
  #chat-input-area {
142
+ padding: 16px;
143
  background: #ffffff;
144
  border-top: 1px solid #f1f5f9;
145
  display: flex;
146
+ gap: 8px;
147
  align-items: center;
148
  }
149
 
150
  #chat-input {
151
  flex: 1;
152
  border: 1px solid #e2e8f0;
153
+ border-radius: 20px;
154
+ padding: 12px 16px;
155
  font-size: 14px;
156
  outline: none;
157
+ transition: border-color 0.2s;
158
+ font-family: inherit;
159
+ box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
160
  }
161
 
162
  #chat-input:focus {
163
  border-color: #10b981;
164
+ }
165
+
166
+ #chat-input:disabled {
167
+ background: #f1f5f9;
168
+ cursor: not-allowed;
169
  }
170
 
171
  #chat-send {
172
+ background: #10b981;
173
  color: white;
174
  border: none;
175
+ width: 44px;
176
+ height: 44px;
177
  border-radius: 50%;
178
  display: flex;
179
  align-items: center;
180
  justify-content: center;
181
  cursor: pointer;
182
+ transition: background 0.2s, transform 0.1s;
183
+ }
184
+
185
+ #chat-send:hover {
186
+ background: #059669;
187
  }
188
 
189
+ #chat-send:active {
190
+ transform: scale(0.95);
191
+ }
192
+
193
+ #chat-send:disabled {
194
+ background: #cbd5e1;
195
+ cursor: not-allowed;
196
+ transform: none;
197
+ }
198
 
199
+ /* Loading / Typing Animation */
200
+ .typing-indicator {
201
+ display: flex;
202
+ gap: 4px;
203
+ padding: 4px 2px;
204
+ align-items: center;
205
+ height: 18px;
206
+ }
207
  .typing-indicator span {
208
+ width: 6px;
209
+ height: 6px;
210
+ background: #94a3b8;
211
+ border-radius: 50%;
212
  animation: typing-dots 1.4s infinite ease-in-out both;
213
  }
214
+ .typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
215
+ .typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
216
  @keyframes typing-dots {
217
+ 0%, 80%, 100% { transform: scale(0); }
218
+ 40% { transform: scale(1); }
219
  }
220
 
221
  @media (max-width: 480px) {
222
  #martech-chat-box {
223
+ right: 15px;
224
+ bottom: 100px;
225
+ width: calc(100vw - 30px);
226
+ height: 70vh;
227
  }
228
  }
229
  </style>
 
236
  <div id="martech-chat-wrapper">
237
  <div id="martech-chat-fab">
238
  <!-- Animated Chatbot Icon -->
239
+ <div id="chat-icon" style="width: 233px; height: 238px; display: flex; align-items: center; justify-content: center; pointer-events: none;">
240
  <dotlottie-player
241
  src="https://joedown11-chatrag.hf.space/static/bot-icon.lottie"
242
+ background="transparent" speed="1" style="width: 100%; height: 100%; will-change: transform;" loop autoplay>
243
  </dotlottie-player>
244
  </div>
245
  <!-- Close Icon -->
 
314
  localStorage.setItem('martech_session_id', sessionId);
315
  }
316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  function appendMessage(role, content) {
318
  const div = document.createElement('div');
319
  div.className = `chat-message ${role}`;
320
+ div.textContent = content;
321
  messagesContainer.appendChild(div);
322
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
323
  return div;
 
419
  'u': 'yihj', 'v': 'cfgb', 'w': 'qase', 'x': 'zsdc', 'y': 'tghu',
420
  'z': 'xas',
421
  };
422
+ const TYPO_CHANCE = 0.07;
423
 
424
  function getNearbyChar(ch) {
425
  const lower = ch.toLowerCase();
 
435
  const sleep = ms => new Promise(r => setTimeout(r, ms));
436
 
437
  async function typeMessageWithTypos(element, text) {
438
+ let displayed = "";
439
+ const words = text.split(" ");
 
 
 
440
 
441
+ for (let i = 0; i < words.length; i++) {
442
+ const word = words[i];
443
+ const separator = i > 0 ? " " : "";
444
+ const isAlpha = /^[a-zA-Z]+$/.test(word);
445
+
446
+ // Randomly insert a typo
447
+ if (i > 0 && word.length > 4 && Math.random() < TYPO_CHANCE && isAlpha) {
448
+ const typoPos = Math.floor(Math.random() * (word.length - 2)) + 2;
449
+
450
+ // 1. Type correct part
451
+ for (let char of (separator + word.substring(0, typoPos))) {
452
+ displayed += char;
453
+ element.textContent = displayed;
454
+ await sleep(Math.random() * 40 + 30);
455
+ }
456
+ // 2. Type wrong char
457
+ const wrongChar = getNearbyChar(word[typoPos]);
458
+ displayed += wrongChar;
459
+ element.textContent = displayed;
460
+ await sleep(Math.random() * 150 + 150); // Realize error
461
+
462
+ // 3. Backspace
463
+ await sleep(Math.random() * 200 + 200);
464
+ displayed = displayed.slice(0, -1);
465
+ element.textContent = displayed;
466
+ await sleep(Math.random() * 100 + 100);
467
+
468
+ // 4. Type rest
469
+ for (let char of word.substring(typoPos)) {
470
+ displayed += char;
471
+ element.textContent = displayed;
472
+ await sleep(Math.random() * 40 + 40);
473
+ }
474
  } else {
475
+ // Type normally
476
+ for (let char of (separator + word)) {
477
+ displayed += char;
478
+ element.textContent = displayed;
479
+ await sleep(char === " " ? Math.random() * 70 + 80 : Math.random() * 40 + 20);
480
  }
481
  }
482
+
483
  messagesContainer.scrollTop = messagesContainer.scrollHeight;
484
+
485
+ // Punctuation pauses
486
+ if (word && [".", "!", "?"].includes(word[word.length - 1])) {
487
+ await sleep(Math.random() * 400 + 400);
488
+ } else if (word && [",", ":", ";"].includes(word[word.length - 1])) {
489
+ await sleep(Math.random() * 200 + 200);
490
+ }
491
  }
492
  }
493