flicker-alerts 1.0.73 → 1.0.75
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 +3 -3
- package/readme.md +4 -0
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.75",
|
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",
|
@@ -18,6 +18,6 @@
|
|
18
18
|
"author": "https://www.linkedin.com/in/bruno-carneiro-9a53aa190/",
|
19
19
|
"license": "MIT",
|
20
20
|
"dependencies": {
|
21
|
-
"flicker-alerts": "^1.0.
|
21
|
+
"flicker-alerts": "^1.0.75"
|
22
22
|
}
|
23
|
-
}
|
23
|
+
}
|
package/readme.md
CHANGED
@@ -52,6 +52,7 @@ FlickerAlerts.showAlert({
|
|
52
52
|
title: 'Sucesso!',
|
53
53
|
message: 'Operação realizada com sucesso.',
|
54
54
|
position: 'top-right' // 'top-right', 'top-left', 'bottom-right', 'bottom-left', 'center'
|
55
|
+
duration: 5000
|
55
56
|
});
|
56
57
|
```
|
57
58
|
|
@@ -73,6 +74,7 @@ export class AppComponent {
|
|
73
74
|
title: 'Atenção!',
|
74
75
|
message: 'Algo deu errado.',
|
75
76
|
position: 'top-center'
|
77
|
+
duration: 5000
|
76
78
|
});
|
77
79
|
}
|
78
80
|
|
@@ -115,6 +117,7 @@ const App = () => {
|
|
115
117
|
title: 'Informação',
|
116
118
|
message: 'Este é um alerta informativo.',
|
117
119
|
position: 'bottom-left'
|
120
|
+
duration: 5000
|
118
121
|
});
|
119
122
|
};
|
120
123
|
|
@@ -154,6 +157,7 @@ Essa abordagem é recomendada para garantir que o estilo seja incluído no build
|
|
154
157
|
| `title` | `string` | Título do alerta. |
|
155
158
|
| `message` | `string` | Mensagem do alerta. |
|
156
159
|
| `position` | `string` | Posição: `top-right`, `top-left`, `bottom-right`, etc. |
|
160
|
+
| `duration` | `number` | Duração do alerta em milissegundos. |
|
157
161
|
|
158
162
|
---
|
159
163
|
|