JSFiddle - React, Tailwind, and code Playground
by Milan Gladiš
HTML
<!-- Start of vectary Zendesk Widget script -->
<script id="ze-snippet" src="https://static.zdassets.com/ekr/snippet.js?key=180150ed-d9fd-4605-94d3-9c7146355178"> </script>
<!-- End of vectary Zendesk Widget script -->
<div class="bubble" id="bubble">
<div class="bubble-agents">
<div class="bubble-agent"></div>
<div class="bubble-agent"></div>
</div>
<div class="bubble-text">
<div class="bubble-status"></div>
<div class="bubble-message">Need Help?</div>
</div>
</div>
CSS
.bubble {
position: absolute;
z-index: 100000;
right: 250px;
bottom: 20px;
background-color: #2B2C3F;
border: 2px solid #6B6C79;
border-radius: 100px;
padding: 0 20px;
height: 46px;
display: flex;
align-items: center;
justify-content: center;
user-select: none;
cursor: default;
transition: all 0.2s ease;
pointer-events: none;
}
.bubble.hidden {
opacity: 0;
margin-bottom: -20px;
}
.bubble.visible {
opacity: 1;
}
.bubble.online:hover .bubble-agent {
border-color: white;
}
.bubble.online, .bubble.offline, .bubble.away {
cursor: pointer;
pointer-events: auto;
}
.bubble.online:hover,
.bubble.offline:hover,
.bubble.away:hover {
background-color: #684CD6;
border-color: transparent;
}
.bubble.online .bubble-message,
.bubble.offline .bubble-message,
.bubble.away .bubble-message {
opacity: 1;
}
.bubble.online .bubble-status::after {
content: "We're Online";
}
.bubble.away .bubble-status::after {
content: "We're Away";
}
/* .bubble.offline .bubble-status::after {
content: "We're Offline";
}
*/
.bubble.online .bubble-status,
.bubble.away .bubble-status {
margin-top: 0;
opacity: 0.4;
}
.bubble.online .bubble-agent,
.bubble.away .bubble-agent {
margin-left: -10px;
margin-right: 5px;
opacity: 1;
border-width: 2px;
border-style: solid;
}
.bubble.online .bubble-agent {
border-color: #39B937;
}
.bubble.away .bubble-agent {
border-color: #FFAE93;
}
.bubble.offline .bubble-agent {
margin-right: -13px;
opacity: 0;
}
.bubble-agents {
display: flex;
}
.bubble-agent {
width: 14px;
height: 14px;
border: 2px solid rgba(255,255,255,0.4);
border-radius: 90px;
margin-left: -5px;
transition: all 0.2s ease;
}
.bubble-status {
font-family: Open Sans;
font-weight: bold;
font-size: 10px;
line-height: 12px;
color: #FFFFFF;
margin-top: -13px;
opacity: 0.4;
transition: all 0.2s ease;
white-space: nowrap;
}
.bubble-status::after {
content:...
JavaScript
var waitForZopim = setInterval(function () {
if (window.$zopim === undefined || window.$zopim.livechat === undefined) {
return;
}
$zopim(function(){
var bubble_el = document.getElementById("bubble");
bubble_el.addEventListener('click', function() {
$zopim.livechat.window.show();
});
$zopim.livechat.setOnConnected(bubble);
$zopim.livechat.setOnStatus(bubble);
$zopim.livechat.window.onShow(function(){
bubble_el.classList.remove("visible");
bubble_el.classList.add("hidden");
});
$zopim.livechat.window.onHide(function(){
bubble_el.classList.remove("hidden");
bubble_el.classList.add("visible");
bubble();
});
$zopim.livechat.setOnChatStart(function(){
$zopim.livechat.window.show();
});
$zopim.livechat.setOnUnreadMsgs(function(){
$zopim.livechat.window.show();
});
function bubble(status){
$zopim.livechat.button.hide();
if(status=='online') {
bubble_el.classList.remove("away", "offline");
bubble_el.classList.add("online");
} else if(status=='away') {
bubble_el.classList.remove("online", "offline");
bubble_el.classList.add("away");
} else if(status=='offline') {
bubble_el.classList.remove("online", "away");
bubble_el.classList.add("offline");
}
}
});
clearInterval(waitForZopim);
}, 100);