Skip to content

Commit 11c49d2

Browse files
authored
Merge pull request #143 from yel-hadd/master
Improve chat tooltip UX with dismissible functionality
2 parents c7ec1bf + 79afffb commit 11c49d2

File tree

1 file changed

+73
-2
lines changed

1 file changed

+73
-2
lines changed

docs/.vuepress/components/Chat.vue

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
</svg>
3030
</button>
3131

32-
<div v-if="!showChat" class="highlight-container">
32+
<div v-if="shouldShowTooltip" class="highlight-container">
3333
<div class="tooltip-text">
34+
<div class="tooltip-close" @click="dismissTooltip">×</div>
3435
<div class="tooltip-title"><b>Need help?</b></div>
3536
<div class="tooltip-subtitle">I'm an AI chatbot, trained to answer all your questions.</div>
3637
</div>
@@ -85,30 +86,63 @@ export default {
8586
isLoading: true,
8687
iframeUrl: "https://chatbot.cloudlinux.com/docs/imunify360",
8788
windowWidth: 0, // Changed from window.innerWidth to avoid SSR error
89+
showTooltip: true,
90+
tooltipDismissDuration: 2 * 60 * 60 * 1000, // 2 hours in milliseconds
8891
};
8992
},
9093
computed: {
9194
isMobile() {
9295
return this.windowWidth < 768;
9396
},
97+
shouldShowTooltip() {
98+
return !this.showChat && this.showTooltip;
99+
},
94100
},
95101
mounted() {
96102
window.addEventListener("resize", this.handleResize);
97103
this.handleResize(); // Set initial windowWidth on client-side
104+
this.updateTooltipVisibility(); // Check tooltip dismissal state on mount
98105
},
99106
beforeUnmount() {
100107
window.removeEventListener("resize", this.handleResize);
101108
},
102109
methods: {
103110
toggleChat() {
104111
this.showChat = !this.showChat;
112+
// If chat is opened, dismiss the tooltip for the set duration
113+
if (this.showChat) {
114+
this.dismissTooltip();
115+
}
105116
},
106117
handleResize() {
107118
this.windowWidth = window.innerWidth;
108119
},
109120
onIframeLoad() {
110121
this.isLoading = false;
111122
},
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+
},
112146
},
113147
};
114148
</script>
@@ -188,7 +222,7 @@ mobile-breakpoint = 768px
188222
display: flex;
189223
flex-direction: column;
190224
align-items: flex-end;
191-
pointer-events: none;
225+
pointer-events: auto;
192226
z-index: 10001;
193227
max-width: 90vw;
194228
}
@@ -206,14 +240,51 @@ mobile-breakpoint = 768px
206240
box-shadow: 0 0 15px $primary-color;
207241
overflow: visible;
208242
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 #ddd;
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: #666;
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: #f5f5f5;
273+
transform: scale(1.1);
274+
color: #333;
275+
}
209276
}
210277
211278
.tooltip-title {
212279
margin-bottom: 4px;
280+
position: relative;
281+
z-index: 2;
213282
}
214283
215284
.tooltip-subtitle {
216285
white-space: nowrap;
286+
position: relative;
287+
z-index: 2;
217288
}
218289
219290
.chat-container {

0 commit comments

Comments
 (0)