aumera-on-screen-widget 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +91 -0
- package/df-btn.js +259 -0
- package/package.json +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Aumera
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# Aumera Chat Widget
|
|
2
|
+
|
|
3
|
+
A lightweight, customizable chat widget that can be easily integrated into any website. The widget provides a floating chat button with smooth animations and responsive design.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install aumera-chat-widget
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Basic Implementation
|
|
14
|
+
|
|
15
|
+
Add the following script tag to your HTML:
|
|
16
|
+
|
|
17
|
+
```html
|
|
18
|
+
<script
|
|
19
|
+
src="df-btn.js"
|
|
20
|
+
id="df-btn"
|
|
21
|
+
project="your-project-id"
|
|
22
|
+
width="390px"
|
|
23
|
+
height="844px"
|
|
24
|
+
openText="Chat"
|
|
25
|
+
closeText="Close"
|
|
26
|
+
logo="assets/logo.svg"
|
|
27
|
+
background="#FEFFFF"
|
|
28
|
+
backgroundDark="#171717"
|
|
29
|
+
logoDark="assets/logo_dark.svg"
|
|
30
|
+
position="right"
|
|
31
|
+
animation="shake"
|
|
32
|
+
shakeDuration="1000"
|
|
33
|
+
shakeInterval="500"
|
|
34
|
+
shakeAmplitude="5"
|
|
35
|
+
shakeFrequency="1"
|
|
36
|
+
showNotification="true"
|
|
37
|
+
></script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Configuration Options
|
|
41
|
+
|
|
42
|
+
| Attribute | Type | Default | Description |
|
|
43
|
+
|-----------|------|---------|-------------|
|
|
44
|
+
| project | string | required | Your project ID |
|
|
45
|
+
| width | string | "400px" | Width of the chat window |
|
|
46
|
+
| height | string | "600px" | Height of the chat window |
|
|
47
|
+
| openText | string | "Chat" | Text shown when chat is closed |
|
|
48
|
+
| closeText | string | "Close" | Text shown when chat is open |
|
|
49
|
+
| logo | string | - | URL to your logo image |
|
|
50
|
+
| background | string | "#FEFFFF" | Background color of the button |
|
|
51
|
+
| backgroundDark | string | "#171717" | Background color in dark mode |
|
|
52
|
+
| logoDark | string | - | URL to your dark mode logo |
|
|
53
|
+
| position | string | "right" | Position of the button ("left" or "right") |
|
|
54
|
+
| animation | string | "message" | Animation type ("shake" or "message") |
|
|
55
|
+
| shakeDuration | number | 3000 | Duration of shake animation in milliseconds |
|
|
56
|
+
| shakeInterval | number | 1000 | Interval between shakes in milliseconds |
|
|
57
|
+
| shakeAmplitude | number | 10 | Amplitude of shake animation in pixels |
|
|
58
|
+
| shakeFrequency | number | 1 | Frequency of shake animation |
|
|
59
|
+
| showNotification | boolean | false | Show notification bubble |
|
|
60
|
+
|
|
61
|
+
### Responsive Design
|
|
62
|
+
|
|
63
|
+
The widget is fully responsive and adapts to mobile screens. On screens smaller than 720px:
|
|
64
|
+
- The button expands to full width
|
|
65
|
+
- The chat window takes up the full viewport height
|
|
66
|
+
- Text labels are hidden for a cleaner look
|
|
67
|
+
|
|
68
|
+
### Dark Mode Support
|
|
69
|
+
|
|
70
|
+
The widget automatically supports dark mode using the `prefers-color-scheme` media query. You can customize the dark mode appearance using the `backgroundDark` and `logoDark` attributes.
|
|
71
|
+
|
|
72
|
+
## Development
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Clone the repository
|
|
76
|
+
git clone https://github.com/yourusername/aumera-chat-widget.git
|
|
77
|
+
|
|
78
|
+
# Install dependencies
|
|
79
|
+
npm install
|
|
80
|
+
|
|
81
|
+
# Build the project
|
|
82
|
+
npm run build
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## License
|
|
86
|
+
|
|
87
|
+
MIT
|
|
88
|
+
|
|
89
|
+
## Contributing
|
|
90
|
+
|
|
91
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
package/df-btn.js
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
const wrapper = document.querySelector("#df-btn");
|
|
2
|
+
const config = {
|
|
3
|
+
src: wrapper.getAttribute("src"),
|
|
4
|
+
project: wrapper.getAttribute("project"),
|
|
5
|
+
width: wrapper.getAttribute("width"),
|
|
6
|
+
height: wrapper.getAttribute("height"),
|
|
7
|
+
openText: wrapper.getAttribute("openText"),
|
|
8
|
+
closeText: wrapper.getAttribute("closeText"),
|
|
9
|
+
background: wrapper.getAttribute("background"),
|
|
10
|
+
backgroundDark: wrapper.getAttribute("backgroundDark"),
|
|
11
|
+
logo: wrapper.getAttribute("logo"),
|
|
12
|
+
logoDark: wrapper.getAttribute("logoDark"),
|
|
13
|
+
position: wrapper.getAttribute("position") || "right",
|
|
14
|
+
animation: wrapper.getAttribute("animation") || "message",
|
|
15
|
+
shakeDuration: parseInt(wrapper.getAttribute("shakeDuration")) || 3000,
|
|
16
|
+
shakeInterval: parseInt(wrapper.getAttribute("shakeInterval")) || 1000,
|
|
17
|
+
shakeAmplitude: parseInt(wrapper.getAttribute("shakeAmplitude")) || 10,
|
|
18
|
+
shakeFrequency: parseInt(wrapper.getAttribute("shakeFrequency")) || 1,
|
|
19
|
+
showNotification: wrapper.getAttribute("showNotification") === "true",
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const origin = config.src.substring(0, config.src.lastIndexOf("/"));
|
|
23
|
+
|
|
24
|
+
if (!config.project) {
|
|
25
|
+
console.warn("Please specify your project ID in attributes!");
|
|
26
|
+
} else {
|
|
27
|
+
const style = document.createElement("style");
|
|
28
|
+
style.innerHTML = `
|
|
29
|
+
.df-btn {
|
|
30
|
+
padding: 0;
|
|
31
|
+
border: none;
|
|
32
|
+
box-shadow: 0 1px 2px 0 rgba(60,64,67,0.302),0 1px 3px 1px rgba(60,64,67,0.149);
|
|
33
|
+
font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
|
34
|
+
background-color: ${config.background || "#FEFFFF"};
|
|
35
|
+
border-radius: 24px;
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
transition: all .45s cubic-bezier(.4, 0, .2, 1);
|
|
38
|
+
position: fixed;
|
|
39
|
+
bottom: 0px;
|
|
40
|
+
${config.position === "left" ? "left: 0px;" : "right: 0px;"}
|
|
41
|
+
margin: 16px;
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-direction: column;
|
|
44
|
+
z-index: 999
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.df-notification {
|
|
48
|
+
position: absolute;
|
|
49
|
+
top: -45px;
|
|
50
|
+
${config.position === "left" ? "left: 0;" : "right: 0;"}
|
|
51
|
+
background: #202124;
|
|
52
|
+
color: white;
|
|
53
|
+
padding: 8px 16px;
|
|
54
|
+
border-radius: 8px;
|
|
55
|
+
font-size: 13px;
|
|
56
|
+
opacity: 0;
|
|
57
|
+
transform: translateY(10px);
|
|
58
|
+
transition: all 0.3s ease;
|
|
59
|
+
white-space: nowrap;
|
|
60
|
+
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
|
|
61
|
+
pointer-events: none;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.df-notification:after {
|
|
65
|
+
content: '';
|
|
66
|
+
position: absolute;
|
|
67
|
+
bottom: -6px;
|
|
68
|
+
${config.position === "left" ? "left: 20px;" : "right: 20px;"}
|
|
69
|
+
width: 0;
|
|
70
|
+
height: 0;
|
|
71
|
+
border-left: 6px solid transparent;
|
|
72
|
+
border-right: 6px solid transparent;
|
|
73
|
+
border-top: 6px solid #202124;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.df-notification.show {
|
|
77
|
+
opacity: 1;
|
|
78
|
+
transform: translateY(0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.df-btn-text {
|
|
82
|
+
min-width: 56px;
|
|
83
|
+
color: #3c4043;
|
|
84
|
+
display: inline-flex;
|
|
85
|
+
align-items: center;
|
|
86
|
+
font-weight: 500;
|
|
87
|
+
padding: 0 24px 0 0;
|
|
88
|
+
font-size: .875rem;
|
|
89
|
+
height: 48px
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.df-btn-text:before {
|
|
93
|
+
min-width: 56px;
|
|
94
|
+
height: 48px;
|
|
95
|
+
background-position: center;
|
|
96
|
+
background-repeat: no-repeat;
|
|
97
|
+
background-size: 24px;
|
|
98
|
+
background-image: url('${config.logo || origin + "/assets/logo.svg"}');
|
|
99
|
+
content: ''
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.df-btn:hover {
|
|
103
|
+
box-shadow: 0 1px 3px 0 rgba(60,64,67,0.302), 0 4px 8px 3px rgba(60,64,67,0.149)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.df-btn:not(.df-closed){
|
|
107
|
+
border-radius: 16px
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.df-btn:not(.df-closed) > .df-btn-text:before {
|
|
111
|
+
background-image: url('${origin}/assets/close.svg')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.df-btn-content {
|
|
115
|
+
display: block;
|
|
116
|
+
border: 0;
|
|
117
|
+
height: ${config.height || "600px"};
|
|
118
|
+
width: ${config.width || "400px"};
|
|
119
|
+
transition: all .45s cubic-bezier(.4, 0, .2, 1);
|
|
120
|
+
${config.position === "left" ? "float: left;" : "float: right;"}
|
|
121
|
+
opacity: 1
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.df-btn:not(.df-closed) > .df-btn-content {
|
|
125
|
+
padding-bottom: 16px;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.df-closed > .df-btn-content {
|
|
129
|
+
width: 0;
|
|
130
|
+
height: 0;
|
|
131
|
+
opacity: 0
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
@media screen and (max-width: 720px){
|
|
135
|
+
.df-btn {
|
|
136
|
+
border-radius: 28px;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.df-btn:not(.df-closed) {
|
|
140
|
+
margin: 0px;
|
|
141
|
+
border-radius: 0px
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.df-btn:not(.df-closed) > .df-btn-content {
|
|
145
|
+
width: 100vw;
|
|
146
|
+
max-height: 100vh;
|
|
147
|
+
height: calc(100vh - 56px);
|
|
148
|
+
padding-bottom: 0px
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.df-btn-text {
|
|
152
|
+
padding: 0;
|
|
153
|
+
height: 56px;
|
|
154
|
+
font-size: 0;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
@media (prefers-color-scheme: dark){
|
|
159
|
+
.df-btn {
|
|
160
|
+
background-color: ${config.backgroundDark || "#171717"}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.df-btn-text {
|
|
164
|
+
color: white
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.df-btn-text:before {
|
|
168
|
+
background-image: url('${
|
|
169
|
+
config.logoDark || origin + "/assets/logo_dark.svg"
|
|
170
|
+
}')
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.df-btn:not(.df-closed) > .df-btn-text:before {
|
|
174
|
+
background-image: url('${origin}/assets/close_dark.svg')
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@keyframes shake {
|
|
179
|
+
0%, 100% { transform: translateX(0); }
|
|
180
|
+
10%, 30%, 50%, 70%, 90% { transform: translateX(-${config.shakeAmplitude}px); }
|
|
181
|
+
20%, 40%, 60%, 80% { transform: translateX(${config.shakeAmplitude}px); }
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
.df-btn.shake {
|
|
185
|
+
animation: shake ${config.shakeDuration/1000}s cubic-bezier(.36,.07,.19,.97) both;
|
|
186
|
+
}
|
|
187
|
+
`;
|
|
188
|
+
|
|
189
|
+
document.head.appendChild(style);
|
|
190
|
+
document.write(`
|
|
191
|
+
<button class="df-btn df-closed" onclick="dfToggle()">
|
|
192
|
+
${config.showNotification ? '<div class="df-notification">Click to check messages</div>' : ''}
|
|
193
|
+
<div class="df-btn-text">${config.openText || "Chat"}</div>
|
|
194
|
+
<iframe class="df-btn-content" src="https://chat.dev.aumera.ai/frame" allow="microphone *"></iframe>
|
|
195
|
+
</button>
|
|
196
|
+
`);
|
|
197
|
+
|
|
198
|
+
let dfToggled = false;
|
|
199
|
+
let inactivityTimer = null;
|
|
200
|
+
let shakeInterval = null;
|
|
201
|
+
|
|
202
|
+
const startInactivityTimer = () => {
|
|
203
|
+
inactivityTimer = setTimeout(() => {
|
|
204
|
+
if (config.showNotification) {
|
|
205
|
+
const notification = document.querySelector(".df-notification");
|
|
206
|
+
if (notification) {
|
|
207
|
+
notification.classList.add("show");
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (config.animation === "shake") {
|
|
212
|
+
const button = document.querySelector(".df-btn");
|
|
213
|
+
const shakeButton = () => {
|
|
214
|
+
button.classList.add("shake");
|
|
215
|
+
setTimeout(() => {
|
|
216
|
+
button.classList.remove("shake");
|
|
217
|
+
}, config.shakeDuration);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// Initial shake
|
|
221
|
+
shakeButton();
|
|
222
|
+
|
|
223
|
+
// Set up interval for repeated shakes
|
|
224
|
+
shakeInterval = setInterval(shakeButton, config.shakeInterval);
|
|
225
|
+
}
|
|
226
|
+
}, 5000);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const resetInactivityTimer = () => {
|
|
230
|
+
if (inactivityTimer) {
|
|
231
|
+
clearTimeout(inactivityTimer);
|
|
232
|
+
}
|
|
233
|
+
if (shakeInterval) {
|
|
234
|
+
clearInterval(shakeInterval);
|
|
235
|
+
}
|
|
236
|
+
startInactivityTimer();
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
window.dfToggle = () => {
|
|
240
|
+
document.querySelector(".df-btn").classList = dfToggled
|
|
241
|
+
? "df-btn df-closed"
|
|
242
|
+
: "df-btn";
|
|
243
|
+
document.querySelector(".df-btn-text").innerText = dfToggled
|
|
244
|
+
? config.openText || "Chat"
|
|
245
|
+
: config.closeText || "Close";
|
|
246
|
+
if (config.showNotification) {
|
|
247
|
+
const notification = document.querySelector(".df-notification");
|
|
248
|
+
if (notification) {
|
|
249
|
+
notification.classList.remove("show");
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
dfToggled = !dfToggled;
|
|
253
|
+
resetInactivityTimer();
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
// Start the inactivity timer when the page loads
|
|
257
|
+
startInactivityTimer();
|
|
258
|
+
|
|
259
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "aumera-on-screen-widget",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A lightweight, customizable chat widget for websites",
|
|
5
|
+
"main": "df-btn.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"chat",
|
|
11
|
+
"widget",
|
|
12
|
+
"aumera",
|
|
13
|
+
"customer-support",
|
|
14
|
+
"live-chat"
|
|
15
|
+
],
|
|
16
|
+
"author": "Aumera",
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "git+https://github.com/yourusername/aumera-chat-widget.git"
|
|
21
|
+
},
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/yourusername/aumera-chat-widget/issues"
|
|
24
|
+
},
|
|
25
|
+
"homepage": "https://github.com/yourusername/aumera-chat-widget#readme",
|
|
26
|
+
"files": [
|
|
27
|
+
"df-btn.js",
|
|
28
|
+
"README.md",
|
|
29
|
+
"LICENSE"
|
|
30
|
+
]
|
|
31
|
+
}
|