yelda-webchat 1.1.7 → 1.1.8

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yelda-webchat",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "description": "Website Chat Plugin",
5
5
  "main": "./dist/js/yeldaWebchatInjector.min.js",
6
6
  "license": "MIT",
@@ -48,6 +48,12 @@
48
48
  font-size: 35px !important;
49
49
  }
50
50
 
51
+ .yelda_container {
52
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
53
+ 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
54
+ font-weight: normal;
55
+ }
56
+
51
57
  .yelda_container.inner {
52
58
  position: absolute !important;
53
59
  left: 45px;
@@ -140,56 +146,59 @@
140
146
  }
141
147
  /** CSS for assistant bubble text */
142
148
  #yelda_assistant_bubble_text {
149
+ animation: 1s ease-out 0s 1 fadeAndSlideInFromRight;
143
150
  position: absolute;
144
- white-space: nowrap;
145
- text-align: center;
146
- transform: translate(-104%, -140%);
147
- padding: 5px;
148
- border: 1px solid #000000;
149
- border-radius: 3px;
150
- box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
151
+ padding: 7px 10px;
152
+ border-radius: 8px;
153
+ box-shadow: #00000030 0px 2px 8px 0px;
151
154
  background-color: white;
152
155
  cursor: pointer;
153
- animation: 1s ease-out 0s 1 fadeAndSlideInFromRight;
156
+ right: 0;
157
+ bottom: 76px;
158
+ max-width: 300px;
159
+ width: calc(66vw);
160
+ text-align: left;
161
+ font-size: 14px;
162
+ font-weight: normal;
154
163
  }
155
164
 
156
165
  #yelda_assistant_bubble_text.hidden {
157
166
  display: none;
158
167
  }
159
168
 
160
- /** css for adding tooltip like triangle to the assistant bubble text */
161
- #yelda_assistant_bubble_text::before,
162
- #yelda_assistant_bubble_text::after {
163
- content: "";
164
- position: absolute;
165
- border-top: 5px solid transparent;
166
- border-bottom: 5px solid transparent;
167
- top: 50%;
168
- left: 100%;
169
+ /* Close button for bubble text */
170
+ .bubbleCloseButton {
171
+ position: relative;
172
+ top: -17px;
173
+ left: 95%;
174
+ color: white;
175
+ background: grey;
176
+ border-radius: 50%;
177
+ padding: 1px 4px;
178
+ font-size: 16px;
179
+ visibility: hidden; /* Don't show the close button by default */
169
180
  }
170
181
 
171
- /* The border of the triangle */
172
- #yelda_assistant_bubble_text::before {
173
- border-left: 10px solid #000;
174
- margin-top: -5px;
175
- margin-left: 1px;
182
+ /* Show the close button on mouse hover */
183
+ #yelda_assistant_bubble_text:hover .bubbleCloseButton {
184
+ visibility: visible;
176
185
  }
177
186
 
178
- /* The white fill of the triangle */
179
- #yelda_assistant_bubble_text::after {
180
- border-left: 10px solid white;
181
- margin-top: -5px;
182
- z-index: 1;
187
+ /* Show the close button always on mobile screen */
188
+ @media only screen and (max-width: 768px) {
189
+ .bubbleCloseButton {
190
+ visibility: visible !important;
191
+ }
183
192
  }
184
193
 
185
194
  /** Animation for assistant bubble text */
186
195
  @keyframes fadeAndSlideInFromRight {
187
196
  0% {
188
- transform: translateX(0%) translateY(-140%);
197
+ transform: translateY(10%);
189
198
  opacity: 0;
190
199
  }
191
200
  100% {
192
- transform: translateX(-104%) translateY(-140%);
201
+ transform: translateY(0%);
193
202
  opacity: 1;
194
203
  }
195
204
  }
@@ -95,7 +95,8 @@ class YeldaChat {
95
95
  // create assistantBubbleText element and set the text
96
96
  this.assistantBubbleText = document.createElement('span')
97
97
  this.assistantBubbleText.setAttribute('id', 'yelda_assistant_bubble_text')
98
- this.assistantBubbleText.innerText = text || this.webchatSettings.bubbleText
98
+ this.assistantBubbleText.innerText = text
99
+ this.addCloseButtonForBubbleText()
99
100
 
100
101
  // Add click event to assistant text
101
102
  this.assistantBubbleText.addEventListener('click', this.openChat.bind(this))
@@ -104,6 +105,31 @@ class YeldaChat {
104
105
  this.webChatContainer.appendChild(this.assistantBubbleText)
105
106
  }
106
107
 
108
+ /**
109
+ * Add close button for bubble text
110
+ */
111
+ addCloseButtonForBubbleText() {
112
+ // Create close button and add it to the bubble text container
113
+ const closeButton = document.createElement('a')
114
+ closeButton.setAttribute('class', 'bubbleCloseButton')
115
+ closeButton.setAttribute('id', 'yelda_assistant_bubble_text_close')
116
+ closeButton.setAttribute('href', '#')
117
+ closeButton.innerHTML = '×'
118
+ closeButton.onclick = this.closeBubbleText.bind(this)
119
+ this.assistantBubbleText.prepend(closeButton)
120
+ }
121
+
122
+ /**
123
+ * Callback function for bubble text close button
124
+ * @param {Event} event
125
+ */
126
+ closeBubbleText(event) {
127
+ event.preventDefault()
128
+ event.stopPropagation()
129
+ this.removeElement('yelda_assistant_bubble_text')
130
+ this.assistantBubbleText = null
131
+ }
132
+
107
133
  /**
108
134
  * Create assistantImage element and add it to webChatContainer element
109
135
  */
@@ -442,7 +468,9 @@ class YeldaChat {
442
468
  }
443
469
  break
444
470
  case config.FRAME_EVENT_TYPES.RECEIVED.ADD_MINIMAL_NOTIFICATION_TEXT:
445
- this.addAssistantBubbleText(eventData.text)
471
+ if (!this.configurationData.hasOwnProperty('canBeClosed') || this.configurationData.canBeClosed) {
472
+ this.addAssistantBubbleText(eventData.text)
473
+ }
446
474
  break;
447
475
  }
448
476
  }