Skip to content

Commit 59383fd

Browse files
author
Suresh
committed
Added a bubble text
1 parent 589da74 commit 59383fd

2 files changed

Lines changed: 50 additions & 8 deletions

File tree

assets.js

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,42 @@ export const styles = `
1919
}
2020
.widget__icon {
2121
cursor: pointer;
22-
width: 100%;
23-
position: absolute;
24-
top: 0px;
25-
left: 0px;
22+
width: 60%;
2623
z-index: 999;
2724
transition: transform .3s ease;
2825
}
26+
27+
.peach-tooltiptext {
28+
width: 100%;
29+
background: #ffffff;
30+
border: 1px solid var(--brandColor);
31+
box-shadow: 0px 2px 9px rgba(0, 0, 0, 0.13);
32+
color: #3a3a3a;
33+
font-size: 14px !important;
34+
line-height: 16.72px;
35+
font-weight: bold;
36+
text-align: center;
37+
display: flex;
38+
flex-direction: column;
39+
justify-content: center;
40+
align-items: center;
41+
position: relative;
42+
border-radius: 4px;
43+
padding: 5px;
44+
animation: peachTooltip-slideUp 1s ease forwards 1s;
45+
}
46+
2947
.widget__hidden {
3048
transform: scale(0);
3149
}
3250
.button__container {
33-
display: block;
51+
display: flex;
52+
flex-direction: column;
53+
text-decoration: none;
54+
align-items: center;
3455
border: none;
35-
width: 60px;
36-
height: 60px;
56+
width: 80px;
57+
height: 80px;
3758
border-radius: 50%;
3859
cursor: pointer;
3960
}
@@ -53,6 +74,17 @@ export const styles = `
5374
font-weight: 400;
5475
margin-bottom: 8px;
5576
}
77+
78+
@keyframes peachTooltip-slideUp {
79+
from {
80+
margin-bottom: 20px;
81+
opacity: 0;
82+
}
83+
to {
84+
margin-bottom: 0px;
85+
opacity: 1;
86+
}
87+
}
5688
`;
5789

5890
export const MESSAGE_ICON = `

main.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,15 @@ class PeachWhatsAppWidget {
4141
buttonContainer.target = "_blank";
4242
buttonContainer.classList.add("button__container");
4343

44+
const tooltipElement = document.createElement("span");
45+
tooltipElement.classList.add("peach-tooltiptext");
46+
tooltipElement.innerHTML = "Chat with us";
47+
buttonContainer.appendChild(tooltipElement);
4448
/**
4549
* Create a span element for the widget icon, give it a class of `widget__icon`, and update its innerHTML property to an icon that would serve as the widget icon.
4650
*/
4751
const widgetIconElement = document.createElement("span");
52+
// <span class="roundicon-tooltiptext">Live Shop</span>
4853
widgetIconElement.innerHTML = MESSAGE_ICON;
4954
widgetIconElement.classList.add("widget__icon");
5055
this.widgetIcon = widgetIconElement;
@@ -74,7 +79,12 @@ class PeachWhatsAppWidget {
7479

7580
injectStyles() {
7681
const styleTag = document.createElement("style");
77-
styleTag.innerHTML = styles.replace(/^\s+|\n/gm, "");
82+
var modifiedStyles = "";
83+
if (this.config.brandColor) {
84+
modifiedStyles = ":root {--brandColor: " + this.config.brandColor + "};\n";
85+
}
86+
modifiedStyles = modifiedStyles + styles;
87+
styleTag.innerHTML = modifiedStyles.replace(/^\s+|\n/gm, "");
7888
document.head.appendChild(styleTag);
7989
}
8090

0 commit comments

Comments
 (0)