aumera-on-screen-widget 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -0,0 +1,5 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg width="800px" height="800px" viewBox="0 0 48 48" fill="none" xmlns="http://www.w3.org/2000/svg">
3
+ <path d="M44 20H28V4" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
4
+ <path d="M4 28H20V44" stroke="#FFFFFF" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"/>
5
+ </svg>
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
3
+ <svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
4
+ <g id="Arrow / Expand">
5
+ <path id="Vector" d="M10 19H5V14M14 5H19V10" stroke="#FFFFFF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
6
+ </g>
7
+ </svg>
package/df-btn.js CHANGED
@@ -98,13 +98,17 @@ if (!config.project) {
98
98
  }
99
99
 
100
100
  .df-btn-text:before {
101
- min-width: 56px;
102
- height: 48px;
103
101
  background-position: center;
104
102
  background-repeat: no-repeat;
105
- background-size: 24px;
106
- background-image: url('${config.logo || origin + "/assets/logo.svg"}');
107
- content: ''
103
+ background-size: cover;
104
+ background-image: url('${origin + "/assets/chat-agent.jpg"}');
105
+ border-radius: 50%;
106
+ width: 32px;
107
+ height: 32px;
108
+ margin: 8px 12px;
109
+ content: '';
110
+ display: inline-block;
111
+ flex-shrink: 0;
108
112
  }
109
113
 
110
114
  .df-btn:hover {
@@ -122,8 +126,8 @@ if (!config.project) {
122
126
  .df-btn-content {
123
127
  display: block;
124
128
  border: 0;
125
- height: ${config.height || "600px"};
126
- width: ${config.width || "400px"};
129
+ height: ${config.height || "896px"};
130
+ width: ${config.width || "414px"};
127
131
  transition: all .45s cubic-bezier(.4, 0, .2, 1);
128
132
  ${config.position === "left" ? "float: left;" : "float: right;"}
129
133
  opacity: 1;
@@ -137,7 +141,8 @@ if (!config.project) {
137
141
  .df-closed > .df-btn-content {
138
142
  width: 0;
139
143
  height: 0;
140
- opacity: 0
144
+ opacity: 0;
145
+ overflow: hidden;
141
146
  }
142
147
 
143
148
  .maximize-minimize-btn {
@@ -159,18 +164,19 @@ if (!config.project) {
159
164
  bottom: 0 !important;
160
165
  margin: 0 !important;
161
166
  border-radius: 0 !important;
167
+ transition: all .45s cubic-bezier(.4, 0, .2, 1) !important;
162
168
  }
163
169
  .df-btn.df-maximized .df-btn-content {
164
170
  width: 100vw !important;
165
171
  height: calc(100vh - 56px) !important;
166
172
  opacity: 1 !important;
167
173
  display: block !important;
174
+ transition: all .45s cubic-bezier(.4, 0, .2, 1) !important;
168
175
  }
169
176
  .df-btn.df-closed .df-btn-content {
170
177
  width: 0 !important;
171
178
  height: 0 !important;
172
179
  opacity: 0 !important;
173
- display: none !important;
174
180
  }
175
181
  .close-btn {
176
182
  width: 16px;
@@ -216,8 +222,7 @@ if (!config.project) {
216
222
  }
217
223
 
218
224
  .df-btn-text:before {
219
- background-image: url('${config.logoDark || origin + "/assets/logo_dark.svg"
220
- }')
225
+ background-image: url('${origin + "/assets/chat-agent.jpg"}')
221
226
  }
222
227
 
223
228
  .df-btn:not(.df-closed) > .df-btn-text:before {
@@ -227,29 +232,55 @@ if (!config.project) {
227
232
 
228
233
  @keyframes shake {
229
234
  0%, 100% { transform: translateX(0); }
230
- 10%, 30%, 50%, 70%, 90% { transform: translateX(-${config.shakeAmplitude
231
- }px); }
232
- 20%, 40%, 60%, 80% { transform: translateX(${config.shakeAmplitude
233
- }px); }
235
+ 10%, 30%, 50%, 70%, 90% { transform: translateX(-${
236
+ config.shakeAmplitude
237
+ }px); }
238
+ 20%, 40%, 60%, 80% { transform: translateX(${
239
+ config.shakeAmplitude
240
+ }px); }
234
241
  }
235
242
 
236
243
  .df-btn.shake {
237
- animation: shake ${config.shakeDuration / 1000
238
- }s cubic-bezier(.36,.07,.19,.97) both;
244
+ animation: shake ${
245
+ config.shakeDuration / 1000
246
+ }s cubic-bezier(.36,.07,.19,.97) both;
239
247
  }
240
248
  `;
241
249
 
242
250
  document.head.appendChild(style);
251
+
252
+ // Language detection function
253
+ function getLanguage() {
254
+ // Check HTML lang attribute first
255
+ let lang = document.documentElement.lang || "";
256
+
257
+ // Fallback to browser language
258
+ if (!lang) {
259
+ lang = navigator.language || navigator.languages?.[0] || "en";
260
+ }
261
+
262
+ // Extract language code (e.g., "en" from "en-US")
263
+ lang = lang.split("-")[0].toLowerCase();
264
+
265
+ // Validate against supported languages
266
+ const supportedLangs = ["en", "de", "it", "fr", "es"];
267
+ return supportedLangs.includes(lang) ? lang : "de";
268
+ }
269
+
270
+ // Get the detected language
271
+ const detectedLang = getLanguage();
272
+
243
273
  document.write(`
244
274
  <button class="df-btn df-closed" onclick="dfToggle()">
245
- ${config.showNotification
246
- ? '<div class="df-notification">Click to check messages</div>'
247
- : ""
248
- }
275
+ ${
276
+ config.showNotification
277
+ ? '<div class="df-notification">Click to check messages</div>'
278
+ : ""
279
+ }
249
280
  <div class="df-btn-header">
250
281
  <div class="df-btn-text">${config.openText || "Chat"}</div>
251
282
  </div>
252
- <iframe class="df-btn-content" src="https://chat.dev.aumera.ai?orgId=1" allow="microphone *"></iframe>
283
+ <iframe class="df-btn-content" src="https://chat.dev.aumera.ai/${detectedLang}/?orgId=1" allow="microphone *"></iframe>
253
284
  </button>
254
285
  `);
255
286
 
@@ -301,65 +332,74 @@ if (!config.project) {
301
332
 
302
333
  // Add close and maximize/minimize buttons dynamically when chat is open
303
334
  function updateHeaderButtons() {
304
- const header = document.querySelector('.df-btn-header');
335
+ const header = document.querySelector(".df-btn-header");
305
336
  if (!header) return;
306
337
  // Remove existing buttons if any
307
- const oldClose = header.querySelector('.close-btn');
338
+ const oldClose = header.querySelector(".close-btn");
308
339
  if (oldClose) header.removeChild(oldClose);
309
- const oldMax = header.querySelector('.maximize-minimize-btn');
340
+ const oldMax = header.querySelector(".maximize-minimize-btn");
310
341
  if (oldMax) header.removeChild(oldMax);
311
- const btnText = header.querySelector('.df-btn-text');
312
- const btn = document.querySelector('.df-btn');
342
+ const btnText = header.querySelector(".df-btn-text");
343
+ const btn = document.querySelector(".df-btn");
313
344
  if (!btn) return;
314
345
  // If open
315
- if (!btn.classList.contains('df-closed')) {
346
+ if (!btn.classList.contains("df-closed")) {
316
347
  // Set text to Close
317
- if (btnText) btnText.innerText = '';
348
+ if (btnText) btnText.innerText = "";
318
349
  // remove right padding from df-btn-text
319
- btnText.style.paddingRight = '0';
350
+ btnText.style.paddingRight = "0";
320
351
  // Add maximize/minimize button (right)
321
- const maxBtn = document.createElement('div');
322
- maxBtn.className = 'maximize-minimize-btn';
323
- const maximized = btn.classList.contains('df-maximized');
324
- maxBtn.innerHTML = `<img class="maximize-minimize-icon" src="${origin}/assets/${maximized ? 'collapse' : 'expand'}.svg" alt="${maximized ? 'Minimize' : 'Maximize'}" style="width:24px;height:24px;cursor:pointer;" />`;
352
+ const maxBtn = document.createElement("div");
353
+ maxBtn.className = "maximize-minimize-btn";
354
+ const maximized = btn.classList.contains("df-maximized");
355
+ const isDarkMode =
356
+ window.matchMedia &&
357
+ window.matchMedia("(prefers-color-scheme: dark)").matches;
358
+ maxBtn.innerHTML = `<img class="maximize-minimize-icon" src="${origin}/assets/${
359
+ maximized ? "collapse" : "expand"
360
+ }${isDarkMode ? "_dark" : ""}.svg" alt="${
361
+ maximized ? "Minimize" : "Maximize"
362
+ }" style="width:24px;height:24px;cursor:pointer;" />`;
325
363
  header.appendChild(maxBtn);
326
- maxBtn.addEventListener('click', (e) => {
364
+ maxBtn.addEventListener("click", (e) => {
327
365
  e.stopPropagation();
328
366
  maximizeMinimize();
329
367
  });
330
368
  // Add close button (left)
331
- const closeBtn = document.createElement('div');
332
- closeBtn.className = 'close-btn';
333
- closeBtn.innerHTML = `<img src="${origin}/assets/close.svg" alt="Close" style="width:20px;height:20px;cursor:pointer;" />`;
369
+ const closeBtn = document.createElement("div");
370
+ closeBtn.className = "close-btn";
371
+ closeBtn.innerHTML = `<img src="${origin}/assets/close${
372
+ isDarkMode ? "_dark" : ""
373
+ }.svg" alt="Close" style="width:20px;height:20px;cursor:pointer;" />`;
334
374
  header.insertBefore(closeBtn, btnText);
335
- closeBtn.addEventListener('click', (e) => {
375
+ closeBtn.addEventListener("click", (e) => {
336
376
  e.stopPropagation();
337
377
  dfToggle();
338
378
  });
339
379
  } else {
340
380
  // Set text to openText
341
- if (btnText) btnText.innerText = config.openText || 'Chat';
381
+ if (btnText) btnText.innerText = config.openText || "Chat";
342
382
  // add right padding to df-btn-text only if screen size is greater than 720px
343
383
  if (window.innerWidth > 720) {
344
- btnText.style.paddingRight = '24px';
384
+ btnText.style.paddingRight = "24px";
345
385
  }
346
386
  }
347
387
  }
348
388
 
349
389
  function maximizeMinimize() {
350
- const btn = document.querySelector('.df-btn');
390
+ const btn = document.querySelector(".df-btn");
351
391
  if (!btn) return;
352
- btn.classList.toggle('df-maximized');
392
+ btn.classList.toggle("df-maximized");
353
393
  updateHeaderButtons();
354
394
  }
355
395
 
356
396
  function dfToggle() {
357
- const btn = document.querySelector('.df-btn');
397
+ const btn = document.querySelector(".df-btn");
358
398
  if (!btn) return;
359
- btn.classList.toggle('df-closed');
399
+ btn.classList.toggle("df-closed");
360
400
  // Always remove maximized state when closing
361
- if (btn.classList.contains('df-closed')) {
362
- btn.classList.remove('df-maximized');
401
+ if (btn.classList.contains("df-closed")) {
402
+ btn.classList.remove("df-maximized");
363
403
  }
364
404
  updateHeaderButtons();
365
405
  clearInactivityAndShake();
@@ -372,11 +412,11 @@ if (!config.project) {
372
412
  updateHeaderButtons();
373
413
 
374
414
  // Remove onclick from button, handle open/close in JS
375
- const btn = document.querySelector('.df-btn');
415
+ const btn = document.querySelector(".df-btn");
376
416
  btn.onclick = null;
377
- btn.addEventListener('click', (e) => {
417
+ btn.addEventListener("click", (e) => {
378
418
  // Only toggle if chat is closed (popover mode)
379
- if (btn.classList.contains('df-closed')) {
419
+ if (btn.classList.contains("df-closed")) {
380
420
  dfToggle();
381
421
  }
382
422
  // If open, do nothing (let header buttons handle maximize/minimize/close)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aumera-on-screen-widget",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "description": "A lightweight, customizable chat widget for websites",
5
5
  "main": "df-btn.js",
6
6
  "scripts": {