8
8
@click =" toggleChat"
9
9
:class =" { 'chat-open': showChat }"
10
10
>
11
- <svg
11
+ <img
12
12
v-if =" !showChat"
13
- viewBox =" 0 0 16 16"
14
- xmlns =" http://www.w3.org/2000/svg"
15
- fill =" #ffffff"
16
- >
17
- <g id =" SVGRepo_iconCarrier" >
18
- <path fill-rule =" evenodd" clip-rule =" evenodd" d =" M8.48 4h4l.5.5v2.03h.52l.5.5V8l-.5.5h-.52v3l-.5.5H9.36l-2.5 2.76L6 14.4V12H3.5l-.5-.64V8.5h-.5L2 8v-.97l.5-.5H3V4.36L3.53 4h4V2.86A1 1 0 0 1 7 2a1 1 0 0 1 2 0 1 1 0 0 1-.52.83V4zM12 8V5H4v5.86l2.5.14H7v2.19l1.8-2.04.35-.15H12V8zm-2.12.51a2.71 2.71 0 0 1-1.37.74v-.01a2.71 2.71 0 0 1-2.42-.74l-.7.71c.34.34.745.608 1.19.79.45.188.932.286 1.42.29a3.7 3.7 0 0 0 2.58-1.07l-.7-.71zM6.49 6.5h-1v1h1v-1zm3 0h1v1h-1v-1z" ></path >
19
- </g >
20
- </svg >
13
+ src =" ../assets/icons/bot-icon.webp"
14
+ alt =" Bot icon"
15
+ class =" bot-icon"
16
+ />
21
17
<svg
22
18
v-else
23
19
xmlns =" http://www.w3.org/2000/svg"
33
29
</svg >
34
30
</button >
35
31
36
- <div v-if =" !showChat" class =" highlight-container" >
37
- <div class =" tooltip-text" >Try our new Virtual Assistant!</div >
32
+ <div v-if =" shouldShowTooltip" class =" highlight-container" >
33
+ <div class =" tooltip-text" >
34
+ <div class =" tooltip-close" @click =" dismissTooltip" >×</div >
35
+ <div class =" tooltip-title" ><b >Need help?</b ></div >
36
+ <div class =" tooltip-subtitle" >I'm an AI chatbot, trained to answer all your questions.</div >
37
+ </div >
38
38
</div >
39
39
</div >
40
40
44
44
:class =" { fullscreen: isMobile, 'desktop-view': !isMobile }"
45
45
>
46
46
<div class =" chat-header" >
47
- <div class =" header-content" >
48
- <img
49
- :src =" botOptions.botAvatarImg"
50
- alt =" Bot icon"
51
- class =" header-avatar"
52
- />
53
- <span class =" bot-title" >{{ botOptions.botTitle }}</span >
54
- </div >
55
47
<div class =" header-actions" >
56
48
<button class =" close-btn" @click =" toggleChat" >
57
49
<svg
87
79
</template >
88
80
89
81
<script >
90
- import BotIcon from " cl-doc-vue-bot-ui/src/assets/icons/bot.png" ;
91
-
92
82
export default {
93
83
data () {
94
84
return {
95
85
showChat: false ,
96
86
isLoading: true ,
97
- botOptions: {
98
- botAvatarImg: BotIcon,
99
- botTitle: " AI Assistant" ,
100
- },
101
87
iframeUrl: " https://chatbot.cloudlinux.com/docs/imunify360" ,
102
88
windowWidth: 0 , // Changed from window.innerWidth to avoid SSR error
89
+ showTooltip: true ,
90
+ tooltipDismissDuration: 2 * 60 * 60 * 1000 , // 2 hours in milliseconds
103
91
};
104
92
},
105
93
computed: {
106
94
isMobile () {
107
95
return this .windowWidth < 768 ;
108
96
},
97
+ shouldShowTooltip () {
98
+ return ! this .showChat && this .showTooltip ;
99
+ },
109
100
},
110
101
mounted () {
111
102
window .addEventListener (" resize" , this .handleResize );
112
103
this .handleResize (); // Set initial windowWidth on client-side
104
+ this .updateTooltipVisibility (); // Check tooltip dismissal state on mount
113
105
},
114
106
beforeUnmount () {
115
107
window .removeEventListener (" resize" , this .handleResize );
116
108
},
117
109
methods: {
118
110
toggleChat () {
119
111
this .showChat = ! this .showChat ;
112
+ // If chat is opened, dismiss the tooltip for the set duration
113
+ if (this .showChat ) {
114
+ this .dismissTooltip ();
115
+ }
120
116
},
121
117
handleResize () {
122
118
this .windowWidth = window .innerWidth ;
123
119
},
124
120
onIframeLoad () {
125
121
this .isLoading = false ;
126
122
},
123
+ updateTooltipVisibility () {
124
+ const dismissedTime = localStorage .getItem (' imdocs_chatbot_tooltip_dismissed_time' );
125
+ let shouldBeDismissed = false ;
126
+
127
+ if (dismissedTime) {
128
+ const currentTime = new Date ().getTime ();
129
+ // Check if the dismissal duration has passed
130
+ if (currentTime - parseInt (dismissedTime) < this .tooltipDismissDuration ) {
131
+ shouldBeDismissed = true ;
132
+ } else {
133
+ // If duration passed, clear the dismissal time so it can show again
134
+ localStorage .removeItem (' imdocs_chatbot_tooltip_dismissed_time' );
135
+ }
136
+ }
137
+
138
+ // Update tooltip visibility based on dismissal state
139
+ this .showTooltip = ! shouldBeDismissed;
140
+ },
141
+ dismissTooltip () {
142
+ const currentTime = new Date ().getTime ();
143
+ localStorage .setItem (' imdocs_chatbot_tooltip_dismissed_time' , currentTime .toString ());
144
+ this .updateTooltipVisibility ();
145
+ },
127
146
},
128
147
};
129
148
</script >
@@ -162,8 +181,8 @@ mobile-breakpoint = 768px
162
181
163
182
.chat-toggle {
164
183
position : relative
165
- background : $primary-color
166
- border : none
184
+ background : white
185
+ border : 2 px solid $primary-color
167
186
border-radius : 50%
168
187
width : 56px
169
188
height : 56px
@@ -174,9 +193,18 @@ mobile-breakpoint = 768px
174
193
box-shadow : 0 4px 12px rgba (0 ,0 ,0 ,0.15 )
175
194
transition : transform 0.3s ease , box-shadow 0.3s ease
176
195
z-index : 10000
196
+ padding : 0
197
+ overflow : hidden
198
+
199
+ .bot-icon {
200
+ width : calc (100% - 4px )
201
+ height : calc (100% - 4px )
202
+ border-radius : 50%
203
+ object-fit : cover
204
+ }
177
205
178
206
svg {
179
- color : white
207
+ color : $primary-color
180
208
width : 32px
181
209
height : 32px
182
210
}
@@ -190,31 +218,73 @@ mobile-breakpoint = 768px
190
218
.highlight-container {
191
219
position : absolute ;
192
220
bottom : calc (100% + 15px );
193
- left : 50% ;
194
- transform : translateX (- 35% );
221
+ right : 0 ;
195
222
display : flex ;
196
223
flex-direction : column ;
197
- align-items : center ;
198
- pointer-events : none ;
224
+ align-items : flex-end ;
225
+ pointer-events : auto ;
199
226
z-index : 10001 ;
200
227
max-width : 90vw ;
201
228
}
202
229
203
230
.tooltip-text {
204
- background : $primary-color ;
205
- color : white ;
206
- padding : 8 px 16 px ;
231
+ background : white ;
232
+ color : black ;
233
+ padding : 12 px 20 px ;
207
234
border-radius : 20px ;
208
235
font-size : 0.95rem ; /* Increase this value to make the tooltip text larger */
209
236
animation : float 3s ease-in-out infinite ;
210
237
position : relative ;
211
- text-align : center ;
212
- white-space : nowrap ;
238
+ text-align : right ;
213
239
font-weight : 500 ;
214
- box-shadow : 0 4px 12px rgba (0 ,0 ,0 ,0.1 );
215
- max-width : 90vw ;
240
+ box-shadow : 0 0 15px $primary-color ;
216
241
overflow : visible ;
217
242
text-overflow : clip ;
243
+
244
+ /* Stop tooltip animation on hover */
245
+ & :hover {
246
+ animation-play-state : paused ;
247
+ }
248
+ }
249
+
250
+ .tooltip-close {
251
+ position : absolute ;
252
+ top : - 8px ;
253
+ right : - 8px ;
254
+ width : 20px ;
255
+ height : 20px ;
256
+ background : white ;
257
+ border : 1px solid #d d d ;
258
+ border-radius : 50% ;
259
+ display : flex ;
260
+ align-items : center ;
261
+ justify-content : center ;
262
+ cursor : pointer ;
263
+ font-size : 14px ;
264
+ line-height : 1 ;
265
+ color : #6 6 6 ;
266
+ transition : all 0.2s ease ;
267
+ box-shadow : 0 2px 4px rgba (0 ,0 ,0 ,0.1 );
268
+ z-index : 10 ;
269
+ pointer-events : auto ;
270
+
271
+ & :hover {
272
+ background : #f5 f5 f5 ;
273
+ transform : scale (1.1 );
274
+ color : #3 3 3 ;
275
+ }
276
+ }
277
+
278
+ .tooltip-title {
279
+ margin-bottom : 4px ;
280
+ position : relative ;
281
+ z-index : 2 ;
282
+ }
283
+
284
+ .tooltip-subtitle {
285
+ white-space : nowrap ;
286
+ position : relative ;
287
+ z-index : 2 ;
218
288
}
219
289
220
290
.chat-container {
@@ -252,27 +322,9 @@ mobile-breakpoint = 768px
252
322
color : white
253
323
padding : 1rem 1.5rem
254
324
display : flex
255
- justify-content : space-between
325
+ justify-content : flex-end
256
326
align-items : center
257
327
258
- .header-content {
259
- display : flex
260
- align-items : center
261
-
262
- .header-avatar {
263
- width : 32px
264
- height : 32px
265
- border-radius : 50%
266
- margin-right : 10px
267
- object-fit : cover
268
- }
269
-
270
- .bot-title {
271
- font-weight : 600
272
- font-size : 1rem
273
- }
274
- }
275
-
276
328
.header-actions {
277
329
display : flex
278
330
align-items : center
@@ -354,10 +406,10 @@ mobile-breakpoint = 768px
354
406
355
407
@keyframes float {
356
408
0% , 100% {
357
- transform : translateY (0 ) translateX ( - 50 % )
409
+ transform : translateY (0 )
358
410
}
359
411
50% {
360
- transform : translateY (- 4px ) translateX ( - 50 % )
412
+ transform : translateY (- 4px )
361
413
}
362
414
}
363
415
@@ -377,14 +429,16 @@ mobile-breakpoint = 768px
377
429
378
430
.highlight-container {
379
431
bottom : calc (100% + 15px )
380
- right : auto
381
- left : 50%
382
- transform : translateX (- 40% )
432
+ right : 0
383
433
}
384
434
385
435
.tooltip-text {
386
436
font-size : 0.9rem ; /* Adjust this value to change the tooltip text size on mobile devices */
387
- padding : 6px 12px ;
437
+ padding : 10px 16px ;
438
+ max-width : 90vw ;
439
+ }
440
+
441
+ .tooltip-subtitle {
388
442
white-space : nowrap ;
389
443
}
390
444
}
0 commit comments