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,77 @@ export default {
85
86
isLoading: true ,
86
87
iframeUrl: " https://chatbot.cloudlinux.com/docs/cloudlinux" ,
87
88
windowWidth: 0 , // Changed from window.innerWidth to avoid SSR error
89
+ tooltipDismissedTime: null ,
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
+ // Don't show tooltip if chat is open
99
+ if (this .showChat ) {
100
+ return false ;
101
+ }
102
+
103
+ // Don't show tooltip if it was recently dismissed
104
+ if (this .tooltipDismissedTime ) {
105
+ const currentTime = new Date ().getTime ();
106
+ if (currentTime - this .tooltipDismissedTime < this .tooltipDismissDuration ) {
107
+ return false ;
108
+ }
109
+ }
110
+
111
+ return true ;
112
+ },
94
113
},
95
114
mounted () {
96
115
window .addEventListener (" resize" , this .handleResize );
97
116
this .handleResize (); // Set initial windowWidth on client-side
117
+ this .loadTooltipDismissalState ();
98
118
},
99
119
beforeUnmount () {
100
120
window .removeEventListener (" resize" , this .handleResize );
101
121
},
102
122
methods: {
103
123
toggleChat () {
104
124
this .showChat = ! this .showChat ;
125
+ // Dismiss tooltip when chat is opened
126
+ if (this .showChat ) {
127
+ this .dismissTooltip ();
128
+ }
105
129
},
106
130
handleResize () {
107
131
this .windowWidth = window .innerWidth ;
108
132
},
109
133
onIframeLoad () {
110
134
this .isLoading = false ;
111
135
},
136
+ dismissTooltip () {
137
+ const currentTime = new Date ().getTime ();
138
+ this .tooltipDismissedTime = currentTime;
139
+ if (typeof localStorage !== ' undefined' ) {
140
+ localStorage .setItem (' cldocs_chatbot_tooltip_dismissed_time' , currentTime .toString ());
141
+ }
142
+ },
143
+ loadTooltipDismissalState () {
144
+ if (typeof localStorage !== ' undefined' ) {
145
+ const dismissedTime = localStorage .getItem (' cldocs_chatbot_tooltip_dismissed_time' );
146
+ if (dismissedTime) {
147
+ const parsedTime = parseInt (dismissedTime);
148
+ const currentTime = new Date ().getTime ();
149
+
150
+ // If the dismissal duration has passed, clear the stored time
151
+ if (currentTime - parsedTime >= this .tooltipDismissDuration ) {
152
+ localStorage .removeItem (' cldocs_chatbot_tooltip_dismissed_time' );
153
+ this .tooltipDismissedTime = null ;
154
+ } else {
155
+ this .tooltipDismissedTime = parsedTime;
156
+ }
157
+ }
158
+ }
159
+ },
112
160
},
113
161
};
114
162
</script >
@@ -188,7 +236,7 @@ mobile-breakpoint = 768px
188
236
display : flex ;
189
237
flex-direction : column ;
190
238
align-items : flex-end ;
191
- pointer-events : none ;
239
+ pointer-events : auto ;
192
240
z-index : 10001 ;
193
241
max-width : 90vw ;
194
242
}
@@ -206,14 +254,50 @@ mobile-breakpoint = 768px
206
254
box-shadow : 0 0 15px $primary-color ;
207
255
overflow : visible ;
208
256
text-overflow : clip ;
257
+
258
+ & :hover {
259
+ animation-play-state : paused ;
260
+ }
261
+ }
262
+
263
+ .tooltip-close {
264
+ position : absolute ;
265
+ top : - 8px ;
266
+ right : - 8px ;
267
+ width : 20px ;
268
+ height : 20px ;
269
+ background : white ;
270
+ border : 1px solid #d d d ;
271
+ border-radius : 50% ;
272
+ display : flex ;
273
+ align-items : center ;
274
+ justify-content : center ;
275
+ cursor : pointer ;
276
+ font-size : 14px ;
277
+ line-height : 1 ;
278
+ color : #6 6 6 ;
279
+ transition : all 0.2s ease ;
280
+ box-shadow : 0 2px 4px rgba (0 ,0 ,0 ,0.1 );
281
+ z-index : 10 ;
282
+ pointer-events : auto ;
283
+
284
+ & :hover {
285
+ background : #f5 f5 f5 ;
286
+ transform : scale (1.1 );
287
+ color : #3 3 3 ;
288
+ }
209
289
}
210
290
211
291
.tooltip-title {
212
292
margin-bottom : 4px ;
293
+ position : relative ;
294
+ z-index : 2 ;
213
295
}
214
296
215
297
.tooltip-subtitle {
216
298
white-space : nowrap ;
299
+ position : relative ;
300
+ z-index : 2 ;
217
301
}
218
302
219
303
.chat-container {
0 commit comments