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