wineater-bot 1.1.5 → 1.1.7

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.
@@ -1,7 +1,7 @@
1
- var l = Object.defineProperty;
2
- var p = (n, t, e) => t in n ? l(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var r = (n, t, e) => (p(n, typeof t != "symbol" ? t + "" : t, e), e);
4
- const g = `
1
+ var p = Object.defineProperty;
2
+ var g = (i, e, t) => e in i ? p(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
+ var r = (i, e, t) => (g(i, typeof e != "symbol" ? e + "" : e, t), t);
4
+ const h = `
5
5
  @font-face {
6
6
  font-family: 'Poppins';
7
7
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -30,6 +30,24 @@ const g = `
30
30
  box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
31
31
  }
32
32
 
33
+ /* Position class for bottom-right */
34
+ .chat-icon-bottom-right {
35
+ position: fixed;
36
+ bottom: 20px;
37
+ right: 20px;
38
+ /* Other styles for the bottom-right button */
39
+ /* ... */
40
+ }
41
+
42
+ .chat-icon-right-center {
43
+ position: fixed;
44
+ top: 50%;
45
+ right: -100px;
46
+ transform: translateY(-50%) rotate(90deg);
47
+ /* Additional styling for the button */
48
+ /* ... */
49
+ }
50
+
33
51
  #chat-icon img {
34
52
  width: 40px; /* Adjust icon size as needed */
35
53
  height: auto;
@@ -44,13 +62,13 @@ const g = `
44
62
 
45
63
  /* Chat window styles */
46
64
  #chat-window {
65
+ position: fixed;
66
+ bottom: 20px; /* Set to the desired distance from the bottom */
67
+ right: 20px; /* Set to the desired distance from the right */
47
68
  width: 350px; /* Width of the chat window */
48
69
  background-color: white;
49
70
  border-radius: 8px;
50
71
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
51
- position: absolute;
52
- bottom: 80px; /* Positioning from the bottom */
53
- right: 0;
54
72
  display: none; /* Initially hidden */
55
73
  }
56
74
 
@@ -258,13 +276,14 @@ const g = `
258
276
  .typing-indicator.visible {
259
277
  visibility: visible;
260
278
  height: 50px;
261
- }`, d = document.createElement("style");
262
- d.textContent = g;
263
- document.head.appendChild(d);
264
- function c() {
265
- document.getElementById("chat-window").classList.toggle("visible");
266
- }
267
- function h() {
279
+ }`, c = document.createElement("style");
280
+ c.textContent = h;
281
+ document.head.appendChild(c);
282
+ function l() {
283
+ const i = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
284
+ i.classList.contains("visible") ? (i.classList.remove("visible"), e.style.display = "flex") : (i.classList.add("visible"), e.style.display = "none");
285
+ }
286
+ function m() {
268
287
  document.getElementById("chat-window").classList.remove("visible");
269
288
  }
270
289
  function u() {
@@ -273,49 +292,49 @@ function u() {
273
292
  document.addEventListener("DOMContentLoaded", () => {
274
293
  setupCloseButton(), setupOutsideClick();
275
294
  });
276
- const m = ["climats", "telckel", "biobio"];
277
- class f {
278
- constructor(t) {
279
- this.apiEndpoint = t || "https://api.wineater.com/dish/recommendations", this.store = m.find((e) => window.location.href.includes(e)), console.log(this.store);
295
+ const f = ["climats", "telckel", "biobio"];
296
+ class b {
297
+ constructor(e) {
298
+ this.apiEndpoint = e || "https://api.wineater.com/dish/recommendations", this.store = f.find((t) => window.location.href.includes(t)), console.log(this.store);
280
299
  }
281
- async getWineRecommendations(t) {
300
+ async getWineRecommendations(e) {
282
301
  console.log(window.location.href);
283
302
  try {
284
- const e = await fetch(this.apiEndpoint, {
303
+ const t = await fetch(this.apiEndpoint, {
285
304
  method: "POST",
286
305
  headers: {
287
306
  "Content-Type": "application/json"
288
307
  },
289
- body: JSON.stringify({ text: t, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
290
- }), o = await e.json();
291
- if (!e.ok)
292
- throw new Error(`API call failed with status ${e.status}: ${o.message || "No additional error information"}`);
308
+ body: JSON.stringify({ text: e, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
309
+ }), o = await t.json();
310
+ if (!t.ok)
311
+ throw new Error(`API call failed with status ${t.status}: ${o.message || "No additional error information"}`);
293
312
  return o;
294
- } catch (e) {
295
- throw console.error("Fetching wine recommendations failed:", e.message), new Error(`Error in getWineRecommendations: ${e.message}`);
313
+ } catch (t) {
314
+ throw console.error("Fetching wine recommendations failed:", t.message), new Error(`Error in getWineRecommendations: ${t.message}`);
296
315
  }
297
316
  }
298
317
  }
299
- class b {
318
+ class y {
300
319
  constructor() {
301
320
  r(this, "welcomeMessage", "Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?");
302
- this.api = new f(), this.displayFirstMessage(this.welcomeMessage);
321
+ this.api = new b(), this.displayFirstMessage(this.welcomeMessage);
303
322
  }
304
323
  initialize() {
305
324
  document.getElementById("send-button").addEventListener("click", () => this.handleUserInput()), document.getElementById("user-input").addEventListener("keypress", (o) => {
306
325
  o.key === "Enter" && this.handleUserInput();
307
326
  });
308
327
  }
309
- displayFirstMessage(t, e = "api") {
310
- const o = document.getElementById("message-container"), i = document.createElement("div");
311
- i.className = `message ${e}`, i.textContent = t, o.appendChild(i), o.scrollTop = o.scrollHeight;
328
+ displayFirstMessage(e, t = "api") {
329
+ const o = document.getElementById("message-container"), n = document.createElement("div");
330
+ n.className = `message ${t}`, n.textContent = e, o.appendChild(n), o.scrollTop = o.scrollHeight;
312
331
  }
313
332
  async handleUserInput() {
314
- const t = document.getElementById("user-input"), e = t.value.trim();
315
- if (e) {
316
- this.displayMessage(e, "user"), t.value = "", this.showTypingIndicator();
333
+ const e = document.getElementById("user-input"), t = e.value.trim();
334
+ if (t) {
335
+ this.displayMessage(t, "user"), e.value = "", this.showTypingIndicator();
317
336
  try {
318
- const o = await this.api.getWineRecommendations(e);
337
+ const o = await this.api.getWineRecommendations(t);
319
338
  this.hideTypingIndicator(), o && o.length ? this.displayResults(o) : this.displayMessage("No results found.", "api");
320
339
  } catch (o) {
321
340
  this.hideTypingIndicator(), console.error("Error fetching wine recommendations:", o), this.displayMessage("Sorry, something went wrong.", "api");
@@ -328,17 +347,17 @@ class b {
328
347
  hideTypingIndicator() {
329
348
  document.getElementById("typing-indicator").classList.remove("visible");
330
349
  }
331
- displayMessage(t, e) {
332
- const o = document.getElementById("message-container"), i = document.createElement("div");
333
- i.textContent = t, i.className = "message " + e, o.appendChild(i), o.scrollTop = o.scrollHeight;
350
+ displayMessage(e, t) {
351
+ const o = document.getElementById("message-container"), n = document.createElement("div");
352
+ n.textContent = e, n.className = "message " + t, o.appendChild(n), o.scrollTop = o.scrollHeight;
334
353
  }
335
- displayResults(t) {
336
- const e = document.getElementById("message-container");
337
- t.forEach((o) => {
338
- const i = document.createElement("div");
339
- i.className = "wine-item";
354
+ displayResults(e) {
355
+ const t = document.getElementById("message-container");
356
+ e.forEach((o) => {
357
+ const n = document.createElement("div");
358
+ n.className = "wine-item";
340
359
  const s = document.createElement("img");
341
- s.src = o.Image, i.appendChild(s);
360
+ s.src = o.Image, n.appendChild(s);
342
361
  const a = document.createElement("div");
343
362
  a.innerHTML = `
344
363
  <strong>${o.Title}</strong><br>
@@ -346,14 +365,14 @@ class b {
346
365
  Région: ${o.Region}<br>
347
366
  Type: ${o.Type}<br>
348
367
  <a href="${o.Url}" target="_blank">Plus d'infos</a>
349
- `, i.appendChild(a), e.appendChild(i);
350
- }), e.scrollTop = e.scrollHeight;
368
+ `, n.appendChild(a), t.appendChild(n);
369
+ }), t.scrollTop = t.scrollHeight;
351
370
  }
352
371
  }
353
372
  document.addEventListener("DOMContentLoaded", () => {
354
- window.toggleChatWindow = c, window.closeChatWindow = h, window.openChatWindow = u;
373
+ window.toggleChatWindow = l, window.closeChatWindow = m, window.openChatWindow = u;
355
374
  });
356
- function y() {
375
+ function w() {
357
376
  document.body.insertAdjacentHTML("beforeend", `
358
377
  <div id="chatbot-container">
359
378
  <div id="chat-icon" onclick="toggleChatWindow()">
@@ -382,20 +401,26 @@ function y() {
382
401
  </div>
383
402
  `);
384
403
  }
385
- function w() {
386
- document.getElementById("close-btn").addEventListener("click", c);
387
- }
388
404
  function x() {
389
- window.addEventListener("click", function(n) {
390
- const t = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
391
- !t.contains(n.target) && !e.contains(n.target) && t.classList.remove("visible");
405
+ document.getElementById("close-btn").addEventListener("click", l);
406
+ }
407
+ function v() {
408
+ window.addEventListener("click", function(i) {
409
+ const e = document.getElementById("chat-window"), t = document.getElementById("chat-icon");
410
+ !e.contains(i.target) && !t.contains(i.target) && (e.classList.remove("visible"), t.style.display = "flex");
392
411
  });
393
412
  }
413
+ function d(i) {
414
+ console.log(i);
415
+ const e = document.getElementById("chat-icon"), t = document.getElementById("chat-window");
416
+ e.className = "", t.className = "", i === "right-center" ? (e.classList.add("chat-icon-right-center"), t.classList.add("right-center-aligned")) : e.classList.add("chat-icon-bottom-right");
417
+ }
394
418
  typeof window < "u" && window.addEventListener("DOMContentLoaded", () => {
395
- y(), w(), x(), new b().initialize();
419
+ const e = ["climats", "telckel", "biobio"].find((o) => window.location.href.includes(o)) || null;
420
+ w(), x(), v(), d(e && e === "biobio" ? "right-center" : "bottom-right"), new y().initialize();
396
421
  });
397
422
  export {
398
- h as closeChatWindow,
423
+ m as closeChatWindow,
399
424
  u as openChatWindow,
400
- c as toggleChatWindow
425
+ l as toggleChatWindow
401
426
  };
@@ -1,4 +1,4 @@
1
- (function(n,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(n=typeof globalThis<"u"?globalThis:n||self,i(n.WineaterChatbot={}))})(this,function(n){"use strict";var x=Object.defineProperty;var v=(n,i,r)=>i in n?x(n,i,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[i]=r;var h=(n,i,r)=>(v(n,typeof i!="symbol"?i+"":i,r),r);const i=`
1
+ (function(n,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.WineaterChatbot={}))})(this,function(n){"use strict";var v=Object.defineProperty;var E=(n,s,r)=>s in n?v(n,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):n[s]=r;var u=(n,s,r)=>(E(n,typeof s!="symbol"?s+"":s,r),r);const s=`
2
2
  @font-face {
3
3
  font-family: 'Poppins';
4
4
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -27,6 +27,24 @@
27
27
  box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
28
28
  }
29
29
 
30
+ /* Position class for bottom-right */
31
+ .chat-icon-bottom-right {
32
+ position: fixed;
33
+ bottom: 20px;
34
+ right: 20px;
35
+ /* Other styles for the bottom-right button */
36
+ /* ... */
37
+ }
38
+
39
+ .chat-icon-right-center {
40
+ position: fixed;
41
+ top: 50%;
42
+ right: -100px;
43
+ transform: translateY(-50%) rotate(90deg);
44
+ /* Additional styling for the button */
45
+ /* ... */
46
+ }
47
+
30
48
  #chat-icon img {
31
49
  width: 40px; /* Adjust icon size as needed */
32
50
  height: auto;
@@ -41,13 +59,13 @@
41
59
 
42
60
  /* Chat window styles */
43
61
  #chat-window {
62
+ position: fixed;
63
+ bottom: 20px; /* Set to the desired distance from the bottom */
64
+ right: 20px; /* Set to the desired distance from the right */
44
65
  width: 350px; /* Width of the chat window */
45
66
  background-color: white;
46
67
  border-radius: 8px;
47
68
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
48
- position: absolute;
49
- bottom: 80px; /* Positioning from the bottom */
50
- right: 0;
51
69
  display: none; /* Initially hidden */
52
70
  }
53
71
 
@@ -255,13 +273,13 @@
255
273
  .typing-indicator.visible {
256
274
  visibility: visible;
257
275
  height: 50px;
258
- }`,r=document.createElement("style");r.textContent=i,document.head.appendChild(r);function d(){document.getElementById("chat-window").classList.toggle("visible")}function c(){document.getElementById("chat-window").classList.remove("visible")}function l(){document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const u=["climats","telckel","biobio"];class m{constructor(o){this.apiEndpoint=o||"https://api.wineater.com/dish/recommendations",this.store=u.find(t=>window.location.href.includes(t)),console.log(this.store)}async getWineRecommendations(o){console.log(window.location.href);try{const t=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:o,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),e=await t.json();if(!t.ok)throw new Error(`API call failed with status ${t.status}: ${e.message||"No additional error information"}`);return e}catch(t){throw console.error("Fetching wine recommendations failed:",t.message),new Error(`Error in getWineRecommendations: ${t.message}`)}}}class f{constructor(){h(this,"welcomeMessage","Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?");this.api=new m,this.displayFirstMessage(this.welcomeMessage)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",e=>{e.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(o,t="api"){const e=document.getElementById("message-container"),s=document.createElement("div");s.className=`message ${t}`,s.textContent=o,e.appendChild(s),e.scrollTop=e.scrollHeight}async handleUserInput(){const o=document.getElementById("user-input"),t=o.value.trim();if(t){this.displayMessage(t,"user"),o.value="",this.showTypingIndicator();try{const e=await this.api.getWineRecommendations(t);this.hideTypingIndicator(),e&&e.length?this.displayResults(e):this.displayMessage("No results found.","api")}catch(e){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",e),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(o,t){const e=document.getElementById("message-container"),s=document.createElement("div");s.textContent=o,s.className="message "+t,e.appendChild(s),e.scrollTop=e.scrollHeight}displayResults(o){const t=document.getElementById("message-container");o.forEach(e=>{const s=document.createElement("div");s.className="wine-item";const p=document.createElement("img");p.src=e.Image,s.appendChild(p);const g=document.createElement("div");g.innerHTML=`
259
- <strong>${e.Title}</strong><br>
260
- Prix: ${e.Price}<br>
261
- Région: ${e.Region}<br>
262
- Type: ${e.Type}<br>
263
- <a href="${e.Url}" target="_blank">Plus d'infos</a>
264
- `,s.appendChild(g),t.appendChild(s)}),t.scrollTop=t.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=d,window.closeChatWindow=c,window.openChatWindow=l});function b(){document.body.insertAdjacentHTML("beforeend",`
276
+ }`,r=document.createElement("style");r.textContent=s,document.head.appendChild(r);function d(){const i=document.getElementById("chat-window"),t=document.getElementById("chat-icon");i.classList.contains("visible")?(i.classList.remove("visible"),t.style.display="flex"):(i.classList.add("visible"),t.style.display="none")}function c(){document.getElementById("chat-window").classList.remove("visible")}function l(){document.getElementById("chat-window").classList.add("visible")}document.addEventListener("DOMContentLoaded",()=>{setupCloseButton(),setupOutsideClick()});const m=["climats","telckel","biobio"];class f{constructor(t){this.apiEndpoint=t||"https://api.wineater.com/dish/recommendations",this.store=m.find(e=>window.location.href.includes(e)),console.log(this.store)}async getWineRecommendations(t){console.log(window.location.href);try{const e=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:t,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),o=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${o.message||"No additional error information"}`);return o}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class b{constructor(){u(this,"welcomeMessage","Sublimez votre expérience gastronomique. Il vous suffit de donner les détails de votre plat, et obtenez la recommandation de compagnon de vin idéale. Que voulez-vous manger?");this.api=new f,this.displayFirstMessage(this.welcomeMessage)}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",o=>{o.key==="Enter"&&this.handleUserInput()})}displayFirstMessage(t,e="api"){const o=document.getElementById("message-container"),a=document.createElement("div");a.className=`message ${e}`,a.textContent=t,o.appendChild(a),o.scrollTop=o.scrollHeight}async handleUserInput(){const t=document.getElementById("user-input"),e=t.value.trim();if(e){this.displayMessage(e,"user"),t.value="",this.showTypingIndicator();try{const o=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),o&&o.length?this.displayResults(o):this.displayMessage("No results found.","api")}catch(o){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",o),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(t,e){const o=document.getElementById("message-container"),a=document.createElement("div");a.textContent=t,a.className="message "+e,o.appendChild(a),o.scrollTop=o.scrollHeight}displayResults(t){const e=document.getElementById("message-container");t.forEach(o=>{const a=document.createElement("div");a.className="wine-item";const g=document.createElement("img");g.src=o.Image,a.appendChild(g);const h=document.createElement("div");h.innerHTML=`
277
+ <strong>${o.Title}</strong><br>
278
+ Prix: ${o.Price}<br>
279
+ Région: ${o.Region}<br>
280
+ Type: ${o.Type}<br>
281
+ <a href="${o.Url}" target="_blank">Plus d'infos</a>
282
+ `,a.appendChild(h),e.appendChild(a)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=d,window.closeChatWindow=c,window.openChatWindow=l});function y(){document.body.insertAdjacentHTML("beforeend",`
265
283
  <div id="chatbot-container">
266
284
  <div id="chat-icon" onclick="toggleChatWindow()">
267
285
  <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon"> <!-- Update the path to your logo image -->
@@ -287,4 +305,4 @@
287
305
  </div>
288
306
  </div>
289
307
  </div>
290
- `)}function y(){document.getElementById("close-btn").addEventListener("click",d)}function w(){window.addEventListener("click",function(a){const o=document.getElementById("chat-window"),t=document.getElementById("chat-icon");!o.contains(a.target)&&!t.contains(a.target)&&o.classList.remove("visible")})}typeof window<"u"&&window.addEventListener("DOMContentLoaded",()=>{b(),y(),w(),new f().initialize()}),n.closeChatWindow=c,n.openChatWindow=l,n.toggleChatWindow=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
308
+ `)}function w(){document.getElementById("close-btn").addEventListener("click",d)}function x(){window.addEventListener("click",function(i){const t=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!t.contains(i.target)&&!e.contains(i.target)&&(t.classList.remove("visible"),e.style.display="flex")})}function p(i){console.log(i);const t=document.getElementById("chat-icon"),e=document.getElementById("chat-window");t.className="",e.className="",i==="right-center"?(t.classList.add("chat-icon-right-center"),e.classList.add("right-center-aligned")):t.classList.add("chat-icon-bottom-right")}typeof window<"u"&&window.addEventListener("DOMContentLoaded",()=>{const t=["climats","telckel","biobio"].find(o=>window.location.href.includes(o))||null;y(),w(),x(),p(t&&t==="biobio"?"right-center":"bottom-right"),new b().initialize()}),n.closeChatWindow=c,n.openChatWindow=l,n.toggleChatWindow=d,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
package/src/index.js CHANGED
@@ -14,6 +14,7 @@ document.addEventListener('DOMContentLoaded', () => {
14
14
  window.toggleChatWindow = toggleChatWindow;
15
15
  window.closeChatWindow = closeChatWindow;
16
16
  window.openChatWindow = openChatWindow;
17
+
17
18
  });
18
19
 
19
20
  export {
@@ -65,16 +66,42 @@ function setupOutsideClick() {
65
66
  const chatIcon = document.getElementById('chat-icon');
66
67
  if (!chatWindow.contains(event.target) && !chatIcon.contains(event.target)) {
67
68
  chatWindow.classList.remove('visible');
69
+ chatIcon.style.display = 'flex'; // Show the chat icon/button
68
70
  }
69
71
  });
70
72
  }
71
73
 
74
+ // Function to toggle the chat icon position
75
+ function toggleChatIconPosition(position) {
76
+ console.log(position);
77
+ const chatIcon = document.getElementById('chat-icon');
78
+ const chatWindow = document.getElementById('chat-window');
79
+
80
+ chatIcon.className = ''; // Reset classes
81
+ chatWindow.className = ''; // Reset classes
82
+
83
+ if (position === 'right-center') {
84
+ chatIcon.classList.add('chat-icon-right-center');
85
+ chatWindow.classList.add('right-center-aligned');
86
+ } else {
87
+ // Apply bottom-right or other default classes as needed
88
+ chatIcon.classList.add('chat-icon-bottom-right');
89
+ }
90
+ }
91
+
72
92
  // If you want to initialize your chatbot automatically when the script is loaded
73
93
  if (typeof window !== 'undefined') {
74
94
  window.addEventListener('DOMContentLoaded', () => {
95
+ const stores = ['climats', 'telckel', 'biobio'];
96
+ const store = stores.find(value => window.location.href.includes(value)) || null;
75
97
  createChatbotUI(); // Create the UI
76
98
  setupCloseButton();
77
99
  setupOutsideClick();
100
+ if (store && store === 'biobio') {
101
+ toggleChatIconPosition('right-center');
102
+ } else {
103
+ toggleChatIconPosition('bottom-right');
104
+ }
78
105
  const myChatbot = new Chatbot();
79
106
  myChatbot.initialize();
80
107
  });
package/src/js/styles.js CHANGED
@@ -28,6 +28,24 @@ const css = `
28
28
  box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
29
29
  }
30
30
 
31
+ /* Position class for bottom-right */
32
+ .chat-icon-bottom-right {
33
+ position: fixed;
34
+ bottom: 20px;
35
+ right: 20px;
36
+ /* Other styles for the bottom-right button */
37
+ /* ... */
38
+ }
39
+
40
+ .chat-icon-right-center {
41
+ position: fixed;
42
+ top: 50%;
43
+ right: -100px;
44
+ transform: translateY(-50%) rotate(90deg);
45
+ /* Additional styling for the button */
46
+ /* ... */
47
+ }
48
+
31
49
  #chat-icon img {
32
50
  width: 40px; /* Adjust icon size as needed */
33
51
  height: auto;
@@ -42,13 +60,13 @@ const css = `
42
60
 
43
61
  /* Chat window styles */
44
62
  #chat-window {
63
+ position: fixed;
64
+ bottom: 20px; /* Set to the desired distance from the bottom */
65
+ right: 20px; /* Set to the desired distance from the right */
45
66
  width: 350px; /* Width of the chat window */
46
67
  background-color: white;
47
68
  border-radius: 8px;
48
69
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
49
- position: absolute;
50
- bottom: 80px; /* Positioning from the bottom */
51
- right: 0;
52
70
  display: none; /* Initially hidden */
53
71
  }
54
72
 
package/src/js/ui.js CHANGED
@@ -1,6 +1,17 @@
1
1
  export function toggleChatWindow() {
2
2
  const chatWindow = document.getElementById('chat-window');
3
- chatWindow.classList.toggle('visible');
3
+ const chatIcon = document.getElementById('chat-icon');
4
+
5
+ // Check if the chat window is currently visible
6
+ const isWindowOpen = chatWindow.classList.contains('visible');
7
+
8
+ if (isWindowOpen) {
9
+ chatWindow.classList.remove('visible');
10
+ chatIcon.style.display = 'flex'; // Show the chat icon/button
11
+ } else {
12
+ chatWindow.classList.add('visible');
13
+ chatIcon.style.display = 'none'; // Hide the chat icon/button
14
+ }
4
15
  }
5
16
 
6
17
  export function closeChatWindow() {