flicker-alerts 1.0.73 → 1.0.74
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/index.js +12 -19
- package/logo.png +0 -0
- package/package.json +2 -2
package/index.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
const FlickerAlerts = {
|
2
|
-
showAlert: function ({ type, title, message,
|
2
|
+
showAlert: function ({ type, title, message, duration = 3000, position = 'top-right' }) { // duração padrão: 3 segundos
|
3
3
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
4
4
|
let container = document.getElementById('alerts-container');
|
5
5
|
if (!container) {
|
@@ -30,51 +30,44 @@ const FlickerAlerts = {
|
|
30
30
|
icon.innerHTML = `<i class="fas ${iconClass}" style="font-size: 24px;"></i>`;
|
31
31
|
alertBox.appendChild(icon);
|
32
32
|
|
33
|
-
// Divisor
|
34
|
-
const divider = document.createElement('div');
|
35
|
-
divider.className = 'divider';
|
36
|
-
console.log(`Created divider for ${type}`); // Para depuração
|
37
|
-
alertBox.appendChild(divider);
|
38
|
-
|
39
33
|
// Conteúdo
|
40
34
|
const content = document.createElement('div');
|
41
35
|
content.innerHTML = `<div class="title">${title}</div><div class="message">${message}</div>`;
|
42
36
|
alertBox.appendChild(content);
|
43
37
|
|
44
|
-
// Barra de
|
38
|
+
// Barra de progresso
|
45
39
|
const progressBar = document.createElement('div');
|
46
40
|
progressBar.className = 'progress-bar';
|
47
|
-
progressBar.style.animationDuration = `${
|
41
|
+
progressBar.style.animationDuration = `${duration}ms`; // sincroniza com a duração do alerta
|
48
42
|
alertBox.appendChild(progressBar);
|
49
43
|
|
50
|
-
// Botão de
|
44
|
+
// Botão de fechamento
|
51
45
|
const closeButton = document.createElement('div');
|
52
46
|
closeButton.className = 'close';
|
53
47
|
closeButton.innerHTML = '<i class="fas fa-times"></i>';
|
54
|
-
|
55
|
-
const removeAlert = () => {
|
56
|
-
alertBox.style.opacity = '0';
|
57
|
-
setTimeout(() => alertBox.remove(), 300);
|
58
|
-
};
|
59
|
-
|
60
48
|
closeButton.addEventListener('click', () => {
|
49
|
+
clearTimeout(timeoutId); // limpa o timeout quando fechado manualmente
|
61
50
|
removeAlert();
|
62
|
-
clearTimeout(timeoutId);
|
63
51
|
});
|
64
52
|
|
65
53
|
alertBox.appendChild(closeButton);
|
66
54
|
container.appendChild(alertBox);
|
67
55
|
|
56
|
+
// Timeout para remover automaticamente o alerta
|
68
57
|
const timeoutId = setTimeout(() => {
|
69
58
|
removeAlert();
|
70
|
-
},
|
59
|
+
}, duration);
|
60
|
+
|
61
|
+
function removeAlert() {
|
62
|
+
alertBox.style.opacity = '0';
|
63
|
+
setTimeout(() => alertBox.remove(), 300); // atraso para animação de fade-out
|
64
|
+
}
|
71
65
|
}
|
72
66
|
},
|
73
67
|
};
|
74
68
|
|
75
69
|
|
76
70
|
|
77
|
-
|
78
71
|
// Botões de teste - Eles podem ser removidos se não forem necessários
|
79
72
|
if (typeof document !== 'undefined') {
|
80
73
|
document.getElementById('success-btn')?.addEventListener('click', () => {
|
package/logo.png
ADDED
Binary file
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "flicker-alerts",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.74",
|
4
4
|
"repository": "https://www.linkedin.com/in/bruno-carneiro-9a53aa190/",
|
5
5
|
"homepage": "https://flickeralerts.netlify.app/",
|
6
6
|
"description": "Biblioteca para alertas animados",
|
@@ -20,4 +20,4 @@
|
|
20
20
|
"dependencies": {
|
21
21
|
"flicker-alerts": "^1.0.73"
|
22
22
|
}
|
23
|
-
}
|
23
|
+
}
|