wineater-bot 1.1.3 → 1.1.4

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,4 +1,7 @@
1
- const c = `
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 = `
2
5
  @font-face {
3
6
  font-family: 'Poppins';
4
7
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -15,20 +18,27 @@ const c = `
15
18
 
16
19
  /* Styling the chat icon */
17
20
  #chat-icon {
18
- width: 60px;
19
- height: 60px;
20
- background-color: #7E27ED; /* Purple background color */
21
- border-radius: 50%;
22
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
21
+ height: 40px;
22
+ display: flex; /* Use flexbox for alignment */
23
+ align-items: center; /* Center items vertically */
24
+ justify-content: center; /* Center items horizontally */
25
+ padding: 8px 16px; /* Add some padding around the text and image */
26
+ border-radius: 20px; /* Rounded corners for the button */
27
+ background-color: #fff; /* Background color from your style guide */
26
28
  cursor: pointer;
29
+ box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
27
30
  }
28
31
 
29
32
  #chat-icon img {
30
- width: 80%; /* Adjust icon size as needed */
33
+ width: 40px; /* Adjust icon size as needed */
31
34
  height: auto;
35
+ margin-right: 8px;
36
+ }
37
+
38
+ #chat-icon span {
39
+ color: black; /* Text color */
40
+ font-family: 'Poppins', sans-serif; /* Font family from your style guide */
41
+ /* Add more text styles if needed */
32
42
  }
33
43
 
34
44
  /* Chat window styles */
@@ -45,7 +55,7 @@ const c = `
45
55
 
46
56
  /* Header of the chat window */
47
57
  #chat-header {
48
- background-color: #7E27ED;
58
+ background-color: #fff;
49
59
  color: white;
50
60
  padding: 16px;
51
61
  border-top-left-radius: 8px;
@@ -56,10 +66,31 @@ const c = `
56
66
  position: relative; /* Needed for absolute positioning of the close button */
57
67
  }
58
68
 
69
+ /* Powered by and logo styles */
70
+ #powered-by {
71
+ display: flex;
72
+ align-items: center;
73
+ background-color: #fff; /* White background */
74
+ width: 100%;
75
+ border-radius: 16px; /* Rounded corners for the container */
76
+ }
77
+
78
+ #powered-by span {
79
+ font-family: 'Poppins', sans-serif;
80
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
81
+ margin-right: 8px; /* Space between the text and the logo */
82
+ }
83
+
84
+ #chatbot-logo {
85
+ height: 20px; /* Adjust the logo size as needed */
86
+ width: auto; /* Keep the logo's aspect ratio */
87
+ }
88
+
59
89
 
60
90
  /* Style for the close button */
61
91
  #close-btn {
62
92
  font-size: 24px; /* Size of the close button */
93
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
63
94
  cursor: pointer;
64
95
  padding: 0 10px;
65
96
  line-height: 24px;
@@ -67,7 +98,8 @@ const c = `
67
98
 
68
99
  /* Container for messages */
69
100
  #message-container {
70
- max-height: 300px;
101
+ max-height: 500px;
102
+ height: 400px;
71
103
  overflow-y: auto;
72
104
  padding: 15px;
73
105
  background: #f7f7f7; /* Light grey background for the message area */
@@ -93,7 +125,7 @@ const c = `
93
125
 
94
126
  #input-container button {
95
127
  padding: 10px 20px; /* Larger padding for a larger button */
96
- background-color: #5F82FF; /* Button background color from style guide */
128
+ background-color: #7E27ED; /* Button background color from style guide */
97
129
  border: none;
98
130
  color: white;
99
131
  border-radius: 4px;
@@ -186,6 +218,7 @@ const c = `
186
218
  align-items: center;
187
219
  height: 0; /* Adjust as needed */
188
220
  visibility: hidden; /* Start off invisible */
221
+ background-color: #f7f7f7;
189
222
  }
190
223
 
191
224
  .typing-indicator span {
@@ -224,33 +257,27 @@ const c = `
224
257
  .typing-indicator.visible {
225
258
  visibility: visible;
226
259
  height: 50px;
227
- }
228
-
229
- #message-container {
230
- overflow-y: auto;
231
- height: 300px; /* adjust based on your UI needs */
232
- padding: 10px;
233
- }`, r = document.createElement("style");
234
- r.textContent = c;
235
- document.head.appendChild(r);
236
- function d() {
260
+ }`, d = document.createElement("style");
261
+ d.textContent = g;
262
+ document.head.appendChild(d);
263
+ function c() {
237
264
  document.getElementById("chat-window").classList.toggle("visible");
238
265
  }
239
- function l() {
266
+ function h() {
240
267
  document.getElementById("chat-window").classList.remove("visible");
241
268
  }
242
- function p() {
269
+ function u() {
243
270
  document.getElementById("chat-window").classList.add("visible");
244
271
  }
245
272
  document.addEventListener("DOMContentLoaded", () => {
246
273
  setupCloseButton(), setupOutsideClick();
247
274
  });
248
- const g = ["climats", "telckel", "biobio"];
249
- class h {
250
- constructor(n) {
251
- this.apiEndpoint = n || "https://api.wineater.com/dish/recommendations", this.store = g.find((e) => window.location.href.includes(e)), console.log(this.store);
275
+ const m = ["climats", "telckel", "biobio"];
276
+ class f {
277
+ constructor(t) {
278
+ this.apiEndpoint = t || "https://api.wineater.com/dish/recommendations", this.store = m.find((e) => window.location.href.includes(e)), console.log(this.store);
252
279
  }
253
- async getWineRecommendations(n) {
280
+ async getWineRecommendations(t) {
254
281
  console.log(window.location.href);
255
282
  try {
256
283
  const e = await fetch(this.apiEndpoint, {
@@ -258,34 +285,39 @@ class h {
258
285
  headers: {
259
286
  "Content-Type": "application/json"
260
287
  },
261
- body: JSON.stringify({ text: n, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
262
- }), t = await e.json();
288
+ body: JSON.stringify({ text: t, store: this.store ? this.store.toString().charAt(0).toUpperCase() + this.store.slice(1) : void 0 })
289
+ }), o = await e.json();
263
290
  if (!e.ok)
264
- throw new Error(`API call failed with status ${e.status}: ${t.message || "No additional error information"}`);
265
- return t;
291
+ throw new Error(`API call failed with status ${e.status}: ${o.message || "No additional error information"}`);
292
+ return o;
266
293
  } catch (e) {
267
294
  throw console.error("Fetching wine recommendations failed:", e.message), new Error(`Error in getWineRecommendations: ${e.message}`);
268
295
  }
269
296
  }
270
297
  }
271
- class u {
298
+ class b {
272
299
  constructor() {
273
- this.api = new h();
300
+ 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?");
301
+ this.api = new f(), this.displayFirstMessage(this.welcomeMessage);
274
302
  }
275
303
  initialize() {
276
- document.getElementById("send-button").addEventListener("click", () => this.handleUserInput()), document.getElementById("user-input").addEventListener("keypress", (t) => {
277
- t.key === "Enter" && this.handleUserInput();
304
+ document.getElementById("send-button").addEventListener("click", () => this.handleUserInput()), document.getElementById("user-input").addEventListener("keypress", (o) => {
305
+ o.key === "Enter" && this.handleUserInput();
278
306
  });
279
307
  }
308
+ displayFirstMessage(t, e = "api") {
309
+ const o = document.getElementById("message-container"), i = document.createElement("div");
310
+ i.className = `message ${e}`, i.textContent = t, o.appendChild(i), o.scrollTop = o.scrollHeight;
311
+ }
280
312
  async handleUserInput() {
281
- const n = document.getElementById("user-input"), e = n.value.trim();
313
+ const t = document.getElementById("user-input"), e = t.value.trim();
282
314
  if (e) {
283
- this.displayMessage(e, "user"), n.value = "", this.showTypingIndicator();
315
+ this.displayMessage(e, "user"), t.value = "", this.showTypingIndicator();
284
316
  try {
285
- const t = await this.api.getWineRecommendations(e);
286
- this.hideTypingIndicator(), t && t.length ? this.displayResults(t) : this.displayMessage("No results found.", "api");
287
- } catch (t) {
288
- this.hideTypingIndicator(), console.error("Error fetching wine recommendations:", t), this.displayMessage("Sorry, something went wrong.", "api");
317
+ const o = await this.api.getWineRecommendations(e);
318
+ this.hideTypingIndicator(), o && o.length ? this.displayResults(o) : this.displayMessage("No results found.", "api");
319
+ } catch (o) {
320
+ this.hideTypingIndicator(), console.error("Error fetching wine recommendations:", o), this.displayMessage("Sorry, something went wrong.", "api");
289
321
  }
290
322
  }
291
323
  }
@@ -295,63 +327,74 @@ class u {
295
327
  hideTypingIndicator() {
296
328
  document.getElementById("typing-indicator").classList.remove("visible");
297
329
  }
298
- displayMessage(n, e) {
299
- const t = document.getElementById("message-container"), o = document.createElement("div");
300
- o.textContent = n, o.className = "message " + e, t.appendChild(o), t.scrollTop = t.scrollHeight;
330
+ displayMessage(t, e) {
331
+ const o = document.getElementById("message-container"), i = document.createElement("div");
332
+ i.textContent = t, i.className = "message " + e, o.appendChild(i), o.scrollTop = o.scrollHeight;
301
333
  }
302
- displayResults(n) {
334
+ displayResults(t) {
303
335
  const e = document.getElementById("message-container");
304
- n.forEach((t) => {
305
- const o = document.createElement("div");
306
- o.className = "wine-item";
336
+ t.forEach((o) => {
337
+ const i = document.createElement("div");
338
+ i.className = "wine-item";
307
339
  const s = document.createElement("img");
308
- s.src = t.Image, o.appendChild(s);
340
+ s.src = o.Image, i.appendChild(s);
309
341
  const a = document.createElement("div");
310
- a.innerHTML = `<strong>${t.Title}</strong><br>Price: ${t.Price}<br>Region: ${t.Region}<br>Type: ${t.Type}<br><a href="${t.Url}" target="_blank">More Info</a>`, o.appendChild(a), e.appendChild(o);
342
+ a.innerHTML = `
343
+ <strong>${o.Title}</strong><br>
344
+ Prix: ${o.Price}<br>
345
+ Région: ${o.Region}<br>
346
+ Type: ${o.Type}<br>
347
+ <a href="${o.Url}" target="_blank">Plus d'infos</a>
348
+ `, i.appendChild(a), e.appendChild(i);
311
349
  }), e.scrollTop = e.scrollHeight;
312
350
  }
313
351
  }
314
352
  document.addEventListener("DOMContentLoaded", () => {
315
- window.toggleChatWindow = d, window.closeChatWindow = l, window.openChatWindow = p;
353
+ window.toggleChatWindow = c, window.closeChatWindow = h, window.openChatWindow = u;
316
354
  });
317
- function m() {
355
+ function y() {
318
356
  document.body.insertAdjacentHTML("beforeend", `
319
357
  <div id="chatbot-container">
320
358
  <div id="chat-icon" onclick="toggleChatWindow()">
321
- <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon">
359
+ <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 -->
360
+ <span>Accorder le vin au dîner</span>
322
361
  </div>
323
362
 
324
363
  <div id="chat-window" class="hidden">
325
364
  <div id="chat-header">
326
- <span>Wineater</span>
327
- <div id="close-btn">&times;</div>
365
+ <div id="powered-by">
366
+ <span>Powered by</span>
367
+ <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/logo.svg" alt="Wineater Logo" id="chatbot-logo">
368
+ </div>
369
+ <div id="close-btn">&times;</div>
328
370
  </div>
371
+
329
372
  <div id="message-container"></div>
330
373
  <div id="typing-indicator" class="typing-indicator hidden">
331
374
  <span></span><span></span><span></span>
332
375
  </div>
333
376
  <div id="input-container">
334
- <input type="text" id="user-input" placeholder="What's on your plate?">
335
- <button id="send-button">Ask</button>
377
+ <input type="text" id="user-input" placeholder="ex., Salade de thon">
378
+ <button id="send-button">Accorder</button>
336
379
  </div>
337
380
  </div>
338
381
  </div>
339
382
  `);
340
383
  }
341
- function b() {
342
- document.getElementById("close-btn").addEventListener("click", d);
384
+ function w() {
385
+ document.getElementById("close-btn").addEventListener("click", c);
343
386
  }
344
- function f() {
345
- window.addEventListener("click", function(i) {
346
- const n = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
347
- !n.contains(i.target) && !e.contains(i.target) && n.classList.remove("visible");
387
+ function x() {
388
+ window.addEventListener("click", function(n) {
389
+ const t = document.getElementById("chat-window"), e = document.getElementById("chat-icon");
390
+ !t.contains(n.target) && !e.contains(n.target) && t.classList.remove("visible");
348
391
  });
349
392
  }
350
393
  typeof window < "u" && window.addEventListener("DOMContentLoaded", () => {
351
- m(), b(), f(), new u().initialize();
394
+ y(), w(), x(), new b().initialize();
352
395
  });
353
396
  export {
354
- l as closeChatWindow,
355
- p as openChatWindow,
356
- d as toggleChatWindow
397
+ h as closeChatWindow,
398
+ u as openChatWindow,
399
+ c as toggleChatWindow
357
400
  };
@@ -1,4 +1,4 @@
1
- (function(o,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(o=typeof globalThis<"u"?globalThis:o||self,a(o.WineaterChatbot={}))})(this,function(o){"use strict";const a=`
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=`
2
2
  @font-face {
3
3
  font-family: 'Poppins';
4
4
  src: url('https://fonts.googleapis.com/css2?family=Poppins:wght@400&display=swap');
@@ -15,20 +15,27 @@
15
15
 
16
16
  /* Styling the chat icon */
17
17
  #chat-icon {
18
- width: 60px;
19
- height: 60px;
20
- background-color: #7E27ED; /* Purple background color */
21
- border-radius: 50%;
22
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
23
- display: flex;
24
- justify-content: center;
25
- align-items: center;
18
+ height: 40px;
19
+ display: flex; /* Use flexbox for alignment */
20
+ align-items: center; /* Center items vertically */
21
+ justify-content: center; /* Center items horizontally */
22
+ padding: 8px 16px; /* Add some padding around the text and image */
23
+ border-radius: 20px; /* Rounded corners for the button */
24
+ background-color: #fff; /* Background color from your style guide */
26
25
  cursor: pointer;
26
+ box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
27
27
  }
28
28
 
29
29
  #chat-icon img {
30
- width: 80%; /* Adjust icon size as needed */
30
+ width: 40px; /* Adjust icon size as needed */
31
31
  height: auto;
32
+ margin-right: 8px;
33
+ }
34
+
35
+ #chat-icon span {
36
+ color: black; /* Text color */
37
+ font-family: 'Poppins', sans-serif; /* Font family from your style guide */
38
+ /* Add more text styles if needed */
32
39
  }
33
40
 
34
41
  /* Chat window styles */
@@ -45,7 +52,7 @@
45
52
 
46
53
  /* Header of the chat window */
47
54
  #chat-header {
48
- background-color: #7E27ED;
55
+ background-color: #fff;
49
56
  color: white;
50
57
  padding: 16px;
51
58
  border-top-left-radius: 8px;
@@ -56,10 +63,31 @@
56
63
  position: relative; /* Needed for absolute positioning of the close button */
57
64
  }
58
65
 
66
+ /* Powered by and logo styles */
67
+ #powered-by {
68
+ display: flex;
69
+ align-items: center;
70
+ background-color: #fff; /* White background */
71
+ width: 100%;
72
+ border-radius: 16px; /* Rounded corners for the container */
73
+ }
74
+
75
+ #powered-by span {
76
+ font-family: 'Poppins', sans-serif;
77
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
78
+ margin-right: 8px; /* Space between the text and the logo */
79
+ }
80
+
81
+ #chatbot-logo {
82
+ height: 20px; /* Adjust the logo size as needed */
83
+ width: auto; /* Keep the logo's aspect ratio */
84
+ }
85
+
59
86
 
60
87
  /* Style for the close button */
61
88
  #close-btn {
62
89
  font-size: 24px; /* Size of the close button */
90
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
63
91
  cursor: pointer;
64
92
  padding: 0 10px;
65
93
  line-height: 24px;
@@ -67,7 +95,8 @@
67
95
 
68
96
  /* Container for messages */
69
97
  #message-container {
70
- max-height: 300px;
98
+ max-height: 500px;
99
+ height: 400px;
71
100
  overflow-y: auto;
72
101
  padding: 15px;
73
102
  background: #f7f7f7; /* Light grey background for the message area */
@@ -93,7 +122,7 @@
93
122
 
94
123
  #input-container button {
95
124
  padding: 10px 20px; /* Larger padding for a larger button */
96
- background-color: #5F82FF; /* Button background color from style guide */
125
+ background-color: #7E27ED; /* Button background color from style guide */
97
126
  border: none;
98
127
  color: white;
99
128
  border-radius: 4px;
@@ -186,6 +215,7 @@
186
215
  align-items: center;
187
216
  height: 0; /* Adjust as needed */
188
217
  visibility: hidden; /* Start off invisible */
218
+ background-color: #f7f7f7;
189
219
  }
190
220
 
191
221
  .typing-indicator span {
@@ -224,31 +254,36 @@
224
254
  .typing-indicator.visible {
225
255
  visibility: visible;
226
256
  height: 50px;
227
- }
228
-
229
- #message-container {
230
- overflow-y: auto;
231
- height: 300px; /* adjust based on your UI needs */
232
- padding: 10px;
233
- }`,d=document.createElement("style");d.textContent=a,document.head.appendChild(d);function r(){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 g=["climats","telckel","biobio"];class u{constructor(n){this.apiEndpoint=n||"https://api.wineater.com/dish/recommendations",this.store=g.find(e=>window.location.href.includes(e)),console.log(this.store)}async getWineRecommendations(n){console.log(window.location.href);try{const e=await fetch(this.apiEndpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:n,store:this.store?this.store.toString().charAt(0).toUpperCase()+this.store.slice(1):void 0})}),t=await e.json();if(!e.ok)throw new Error(`API call failed with status ${e.status}: ${t.message||"No additional error information"}`);return t}catch(e){throw console.error("Fetching wine recommendations failed:",e.message),new Error(`Error in getWineRecommendations: ${e.message}`)}}}class m{constructor(){this.api=new u}initialize(){document.getElementById("send-button").addEventListener("click",()=>this.handleUserInput()),document.getElementById("user-input").addEventListener("keypress",t=>{t.key==="Enter"&&this.handleUserInput()})}async handleUserInput(){const n=document.getElementById("user-input"),e=n.value.trim();if(e){this.displayMessage(e,"user"),n.value="",this.showTypingIndicator();try{const t=await this.api.getWineRecommendations(e);this.hideTypingIndicator(),t&&t.length?this.displayResults(t):this.displayMessage("No results found.","api")}catch(t){this.hideTypingIndicator(),console.error("Error fetching wine recommendations:",t),this.displayMessage("Sorry, something went wrong.","api")}}}showTypingIndicator(){document.getElementById("typing-indicator").classList.add("visible")}hideTypingIndicator(){document.getElementById("typing-indicator").classList.remove("visible")}displayMessage(n,e){const t=document.getElementById("message-container"),s=document.createElement("div");s.textContent=n,s.className="message "+e,t.appendChild(s),t.scrollTop=t.scrollHeight}displayResults(n){const e=document.getElementById("message-container");n.forEach(t=>{const s=document.createElement("div");s.className="wine-item";const p=document.createElement("img");p.src=t.Image,s.appendChild(p);const h=document.createElement("div");h.innerHTML=`<strong>${t.Title}</strong><br>Price: ${t.Price}<br>Region: ${t.Region}<br>Type: ${t.Type}<br><a href="${t.Url}" target="_blank">More Info</a>`,s.appendChild(h),e.appendChild(s)}),e.scrollTop=e.scrollHeight}}document.addEventListener("DOMContentLoaded",()=>{window.toggleChatWindow=r,window.closeChatWindow=c,window.openChatWindow=l});function b(){document.body.insertAdjacentHTML("beforeend",`
257
+ }`,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=`
258
+ <strong>${e.Title}</strong><br>
259
+ Prix: ${e.Price}<br>
260
+ Région: ${e.Region}<br>
261
+ Type: ${e.Type}<br>
262
+ <a href="${e.Url}" target="_blank">Plus d'infos</a>
263
+ `,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",`
234
264
  <div id="chatbot-container">
235
265
  <div id="chat-icon" onclick="toggleChatWindow()">
236
- <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon">
266
+ <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 -->
267
+ <span>Accorder le vin au dîner</span>
237
268
  </div>
238
269
 
239
270
  <div id="chat-window" class="hidden">
240
271
  <div id="chat-header">
241
- <span>Wineater</span>
242
- <div id="close-btn">&times;</div>
272
+ <div id="powered-by">
273
+ <span>Powered by</span>
274
+ <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/logo.svg" alt="Wineater Logo" id="chatbot-logo">
275
+ </div>
276
+ <div id="close-btn">&times;</div>
243
277
  </div>
278
+
244
279
  <div id="message-container"></div>
245
280
  <div id="typing-indicator" class="typing-indicator hidden">
246
281
  <span></span><span></span><span></span>
247
282
  </div>
248
283
  <div id="input-container">
249
- <input type="text" id="user-input" placeholder="What's on your plate?">
250
- <button id="send-button">Ask</button>
284
+ <input type="text" id="user-input" placeholder="ex., Salade de thon">
285
+ <button id="send-button">Accorder</button>
251
286
  </div>
252
287
  </div>
253
288
  </div>
254
- `)}function f(){document.getElementById("close-btn").addEventListener("click",r)}function y(){window.addEventListener("click",function(i){const n=document.getElementById("chat-window"),e=document.getElementById("chat-icon");!n.contains(i.target)&&!e.contains(i.target)&&n.classList.remove("visible")})}typeof window<"u"&&window.addEventListener("DOMContentLoaded",()=>{b(),f(),y(),new m().initialize()}),o.closeChatWindow=c,o.openChatWindow=l,o.toggleChatWindow=r,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
289
+ `)}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"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wineater-bot",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -14,20 +14,27 @@
14
14
 
15
15
  /* Styling the chat icon */
16
16
  #chat-icon {
17
- width: 60px;
18
- height: 60px;
19
- background-color: #7E27ED; /* Purple background color */
20
- border-radius: 50%;
21
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
22
- display: flex;
23
- justify-content: center;
24
- align-items: center;
17
+ display: flex; /* Use flexbox for alignment */
18
+ align-items: center; /* Center items vertically */
19
+ justify-content: center; /* Center items horizontally */
20
+ padding: 8px; /* Add some padding around the text and image */
21
+ border-radius: 20px; /* Rounded corners for the button */
22
+ background-color: #7E27ED; /* Background color from your style guide */
25
23
  cursor: pointer;
24
+ box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
25
+
26
26
  }
27
27
 
28
28
  #chat-icon img {
29
29
  width: 80%; /* Adjust icon size as needed */
30
30
  height: auto;
31
+ margin-right: 8px;
32
+ }
33
+
34
+ #chat-icon span {
35
+ color: white; /* Text color */
36
+ font-family: 'Poppins', sans-serif; /* Font family from your style guide */
37
+ /* Add more text styles if needed */
31
38
  }
32
39
 
33
40
  /* Chat window styles */
package/src/index.js CHANGED
@@ -26,21 +26,26 @@ function createChatbotUI() {
26
26
  const chatbotHTML = `
27
27
  <div id="chatbot-container">
28
28
  <div id="chat-icon" onclick="toggleChatWindow()">
29
- <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/chat-icon.svg" alt="Chat Icon">
29
+ <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 -->
30
+ <span>Accorder le vin au dîner</span>
30
31
  </div>
31
32
 
32
33
  <div id="chat-window" class="hidden">
33
34
  <div id="chat-header">
34
- <span>Wineater</span>
35
- <div id="close-btn">&times;</div>
35
+ <div id="powered-by">
36
+ <span>Powered by</span>
37
+ <img src="https://landing-static.s3.eu-central-1.amazonaws.com/images/logo.svg" alt="Wineater Logo" id="chatbot-logo">
36
38
  </div>
39
+ <div id="close-btn">&times;</div>
40
+ </div>
41
+
37
42
  <div id="message-container"></div>
38
43
  <div id="typing-indicator" class="typing-indicator hidden">
39
44
  <span></span><span></span><span></span>
40
45
  </div>
41
46
  <div id="input-container">
42
- <input type="text" id="user-input" placeholder="What's on your plate?">
43
- <button id="send-button">Ask</button>
47
+ <input type="text" id="user-input" placeholder="ex., Salade de thon">
48
+ <button id="send-button">Accorder</button>
44
49
  </div>
45
50
  </div>
46
51
  </div>
package/src/js/chatbot.js CHANGED
@@ -4,12 +4,16 @@ import { Api } from './api.js';
4
4
  export class Chatbot {
5
5
  constructor() {
6
6
  this.api = new Api(); // Instantiate the Api class
7
+ this.displayFirstMessage(this.welcomeMessage);
7
8
  }
8
9
 
10
+ 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?";
11
+
9
12
  initialize() {
10
13
  // Attach event listeners
11
14
  const sendButton = document.getElementById('send-button');
12
15
  sendButton.addEventListener('click', () => this.handleUserInput());
16
+
13
17
 
14
18
  const userInputField = document.getElementById('user-input');
15
19
  userInputField.addEventListener('keypress', (event) => {
@@ -19,6 +23,15 @@ export class Chatbot {
19
23
  });
20
24
  }
21
25
 
26
+ displayFirstMessage(message, sender = 'api') {
27
+ const messageContainer = document.getElementById('message-container');
28
+ const messageDiv = document.createElement('div');
29
+ messageDiv.className = `message ${sender}`;
30
+ messageDiv.textContent = message;
31
+ messageContainer.appendChild(messageDiv);
32
+ messageContainer.scrollTop = messageContainer.scrollHeight; // Scroll to the latest message
33
+ }
34
+
22
35
  async handleUserInput() {
23
36
  const inputField = document.getElementById('user-input');
24
37
  const userInput = inputField.value.trim();
@@ -80,7 +93,13 @@ export class Chatbot {
80
93
  wineDiv.appendChild(image);
81
94
 
82
95
  const contentDiv = document.createElement('div');
83
- contentDiv.innerHTML = `<strong>${wine.Title}</strong><br>Price: ${wine.Price}<br>Region: ${wine.Region}<br>Type: ${wine.Type}<br><a href="${wine.Url}" target="_blank">More Info</a>`;
96
+ contentDiv.innerHTML = `
97
+ <strong>${wine.Title}</strong><br>
98
+ Prix: ${wine.Price}<br>
99
+ Région: ${wine.Region}<br>
100
+ Type: ${wine.Type}<br>
101
+ <a href="${wine.Url}" target="_blank">Plus d'infos</a>
102
+ `;
84
103
  wineDiv.appendChild(contentDiv);
85
104
 
86
105
  messageContainer.appendChild(wineDiv);
package/src/js/styles.js CHANGED
@@ -16,20 +16,27 @@ const css = `
16
16
 
17
17
  /* Styling the chat icon */
18
18
  #chat-icon {
19
- width: 60px;
20
- height: 60px;
21
- background-color: #7E27ED; /* Purple background color */
22
- border-radius: 50%;
23
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
24
- display: flex;
25
- justify-content: center;
26
- align-items: center;
19
+ height: 40px;
20
+ display: flex; /* Use flexbox for alignment */
21
+ align-items: center; /* Center items vertically */
22
+ justify-content: center; /* Center items horizontally */
23
+ padding: 8px 16px; /* Add some padding around the text and image */
24
+ border-radius: 20px; /* Rounded corners for the button */
25
+ background-color: #fff; /* Background color from your style guide */
27
26
  cursor: pointer;
27
+ box-shadow: 0 2px 10px rgba(0,0,0,0.2); /* Optional: add shadow for depth */
28
28
  }
29
29
 
30
30
  #chat-icon img {
31
- width: 80%; /* Adjust icon size as needed */
31
+ width: 40px; /* Adjust icon size as needed */
32
32
  height: auto;
33
+ margin-right: 8px;
34
+ }
35
+
36
+ #chat-icon span {
37
+ color: black; /* Text color */
38
+ font-family: 'Poppins', sans-serif; /* Font family from your style guide */
39
+ /* Add more text styles if needed */
33
40
  }
34
41
 
35
42
  /* Chat window styles */
@@ -46,7 +53,7 @@ const css = `
46
53
 
47
54
  /* Header of the chat window */
48
55
  #chat-header {
49
- background-color: #7E27ED;
56
+ background-color: #fff;
50
57
  color: white;
51
58
  padding: 16px;
52
59
  border-top-left-radius: 8px;
@@ -57,10 +64,31 @@ const css = `
57
64
  position: relative; /* Needed for absolute positioning of the close button */
58
65
  }
59
66
 
67
+ /* Powered by and logo styles */
68
+ #powered-by {
69
+ display: flex;
70
+ align-items: center;
71
+ background-color: #fff; /* White background */
72
+ width: 100%;
73
+ border-radius: 16px; /* Rounded corners for the container */
74
+ }
75
+
76
+ #powered-by span {
77
+ font-family: 'Poppins', sans-serif;
78
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
79
+ margin-right: 8px; /* Space between the text and the logo */
80
+ }
81
+
82
+ #chatbot-logo {
83
+ height: 20px; /* Adjust the logo size as needed */
84
+ width: auto; /* Keep the logo's aspect ratio */
85
+ }
86
+
60
87
 
61
88
  /* Style for the close button */
62
89
  #close-btn {
63
90
  font-size: 24px; /* Size of the close button */
91
+ color: #7E27ED; /* Text color - using the primary color from your style guide */
64
92
  cursor: pointer;
65
93
  padding: 0 10px;
66
94
  line-height: 24px;
@@ -68,7 +96,8 @@ const css = `
68
96
 
69
97
  /* Container for messages */
70
98
  #message-container {
71
- max-height: 300px;
99
+ max-height: 500px;
100
+ height: 400px;
72
101
  overflow-y: auto;
73
102
  padding: 15px;
74
103
  background: #f7f7f7; /* Light grey background for the message area */
@@ -94,7 +123,7 @@ const css = `
94
123
 
95
124
  #input-container button {
96
125
  padding: 10px 20px; /* Larger padding for a larger button */
97
- background-color: #5F82FF; /* Button background color from style guide */
126
+ background-color: #7E27ED; /* Button background color from style guide */
98
127
  border: none;
99
128
  color: white;
100
129
  border-radius: 4px;
@@ -187,6 +216,7 @@ const css = `
187
216
  align-items: center;
188
217
  height: 0; /* Adjust as needed */
189
218
  visibility: hidden; /* Start off invisible */
219
+ background-color: #f7f7f7;
190
220
  }
191
221
 
192
222
  .typing-indicator span {
@@ -225,12 +255,6 @@ const css = `
225
255
  .typing-indicator.visible {
226
256
  visibility: visible;
227
257
  height: 50px;
228
- }
229
-
230
- #message-container {
231
- overflow-y: auto;
232
- height: 300px; /* adjust based on your UI needs */
233
- padding: 10px;
234
258
  }`;
235
259
 
236
260
  const style = document.createElement('style');