2
2
<div id =" bot-ui" >
3
3
<!-- Conditionally show toggle button with highlight -->
4
4
<div class =" toggle-container" v-show =" !(isMobile && showChat)" >
5
- <div v-if =" !showChat " class =" pulse-ring" ></div >
5
+ <div v-if =" shouldShowTooltip " class =" pulse-ring" ></div >
6
6
<button
7
7
class =" chat-toggle"
8
8
@click =" toggleChat"
29
29
</svg >
30
30
</button >
31
31
32
- <div v-if =" !showChat " class =" highlight-container" >
32
+ <div v-if =" shouldShowTooltip " class =" highlight-container" >
33
33
<div class =" tooltip-text" >
34
+ <div class =" tooltip-close" @click =" dismissTooltip" >×</div >
34
35
<div class =" tooltip-title" ><b >Need help?</b ></div >
35
36
<div class =" tooltip-subtitle" >I'm an AI chatbot, trained to answer all your questions.</div >
36
37
</div >
@@ -85,30 +86,66 @@ export default {
85
86
isLoading: true ,
86
87
iframeUrl: " https://chatbot.cloudlinux.com/docs/tuxcare" ,
87
88
windowWidth: 0 , // Changed from window.innerWidth to avoid SSR error
89
+ showTooltip: true ,
90
+ tooltipDismissDuration: 2 * 60 * 60 * 1000 , // 2 hours in milliseconds
88
91
};
89
92
},
90
93
computed: {
91
94
isMobile () {
92
95
return this .windowWidth < 768 ;
93
96
},
97
+ shouldShowTooltip () {
98
+ return this .showTooltip && ! this .showChat ;
99
+ },
94
100
},
95
101
mounted () {
96
102
window .addEventListener (" resize" , this .handleResize );
97
103
this .handleResize (); // Set initial windowWidth on client-side
104
+ this .updateTooltipVisibility ();
98
105
},
99
106
beforeUnmount () {
100
107
window .removeEventListener (" resize" , this .handleResize );
101
108
},
102
109
methods: {
103
110
toggleChat () {
104
111
this .showChat = ! this .showChat ;
112
+ if (this .showChat ) {
113
+ this .dismissTooltip ();
114
+ }
105
115
},
106
116
handleResize () {
107
117
this .windowWidth = window .innerWidth ;
108
118
},
109
119
onIframeLoad () {
110
120
this .isLoading = false ;
111
121
},
122
+ dismissTooltip () {
123
+ const currentTime = new Date ().getTime ();
124
+ if (typeof localStorage !== ' undefined' ) {
125
+ localStorage .setItem (' chatbot_tooltip_dismissed_time' , currentTime .toString ());
126
+ }
127
+ this .showTooltip = false ;
128
+ },
129
+ updateTooltipVisibility () {
130
+ if (typeof localStorage === ' undefined' ) {
131
+ this .showTooltip = true ;
132
+ return ;
133
+ }
134
+
135
+ const dismissedTime = localStorage .getItem (' chatbot_tooltip_dismissed_time' );
136
+
137
+ if (dismissedTime) {
138
+ const currentTime = new Date ().getTime ();
139
+ if (currentTime - parseInt (dismissedTime) < this .tooltipDismissDuration ) {
140
+ this .showTooltip = false ;
141
+ } else {
142
+ localStorage .removeItem (' chatbot_tooltip_dismissed_time' );
143
+ this .showTooltip = true ;
144
+ }
145
+ } else {
146
+ this .showTooltip = true ;
147
+ }
148
+ },
112
149
},
113
150
};
114
151
</script >
@@ -188,7 +225,7 @@ mobile-breakpoint = 768px
188
225
display : flex ;
189
226
flex-direction : column ;
190
227
align-items : flex-end ;
191
- pointer-events : none ;
228
+ pointer-events : auto ;
192
229
z-index : 10001 ;
193
230
max-width : 90vw ;
194
231
}
@@ -206,14 +243,51 @@ mobile-breakpoint = 768px
206
243
box-shadow : 0 0 15px $primary-color ;
207
244
overflow : visible ;
208
245
text-overflow : clip ;
246
+
247
+ /* Stop animation on hover */
248
+ & :hover {
249
+ animation-play-state : paused ;
250
+ }
251
+ }
252
+
253
+ .tooltip-close {
254
+ position : absolute ;
255
+ top : - 8px ;
256
+ right : - 8px ;
257
+ width : 20px ;
258
+ height : 20px ;
259
+ background : white ;
260
+ border : 1px solid #d d d ;
261
+ border-radius : 50% ;
262
+ display : flex ;
263
+ align-items : center ;
264
+ justify-content : center ;
265
+ cursor : pointer ;
266
+ font-size : 14px ;
267
+ line-height : 1 ;
268
+ color : #6 6 6 ;
269
+ transition : all 0.2s ease ;
270
+ box-shadow : 0 2px 4px rgba (0 ,0 ,0 ,0.1 );
271
+ z-index : 10 ;
272
+ pointer-events : auto ;
273
+
274
+ & :hover {
275
+ background : #f5 f5 f5 ;
276
+ transform : scale (1.1 );
277
+ color : #3 3 3 ;
278
+ }
209
279
}
210
280
211
281
.tooltip-title {
212
282
margin-bottom : 4px ;
283
+ position : relative ;
284
+ z-index : 2 ;
213
285
}
214
286
215
287
.tooltip-subtitle {
216
288
white-space : nowrap ;
289
+ position : relative ;
290
+ z-index : 2 ;
217
291
}
218
292
219
293
.chat-container {
0 commit comments