flicker-alerts 1.0.76 → 1.0.79
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 +20 -9
- package/package.json +2 -2
- package/readme.md +4 -2
- package/style.css +83 -32
package/index.js
CHANGED
@@ -1,22 +1,29 @@
|
|
1
1
|
const FlickerAlerts = {
|
2
|
-
showAlert: function ({ type, title, message, duration = 3000, position = 'top-right' }) {
|
2
|
+
showAlert: function ({ type, title, message, duration = 3000, position = 'top-right' }) {
|
3
3
|
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
4
4
|
let container = document.getElementById('alerts-container');
|
5
5
|
if (!container) {
|
6
6
|
container = document.createElement('div');
|
7
7
|
container.id = 'alerts-container';
|
8
8
|
container.style.position = 'fixed';
|
9
|
-
container.style.top = 0;
|
10
|
-
container.style.left = 0;
|
11
|
-
container.style.width = '100vw';
|
12
|
-
container.style.height = '100vh';
|
13
9
|
container.style.pointerEvents = 'none';
|
14
10
|
document.body.appendChild(container);
|
11
|
+
|
12
|
+
// Define posição com base no parâmetro
|
13
|
+
const positionStyles = {
|
14
|
+
'top-right': { top: '0', right: '0', flexDirection: 'column' },
|
15
|
+
'top-left': { top: '0', left: '0', flexDirection: 'column' },
|
16
|
+
'bottom-right': { bottom: '0', right: '0', flexDirection: 'column-reverse' },
|
17
|
+
'bottom-left': { bottom: '0', left: '0', flexDirection: 'column-reverse' },
|
18
|
+
'center': { top: '50%', left: '50%', transform: 'translate(-50%, -50%)', flexDirection: 'column' },
|
19
|
+
'top-center': { top: '1rem', left: '50%', transform: 'translateX(-50%)', flexDirection: 'column' },
|
20
|
+
'bottom-center': { bottom: '1rem', left: '50%', transform: 'translateX(-50%)', flexDirection: 'column-reverse' },
|
21
|
+
};
|
22
|
+
Object.assign(container.style, positionStyles[position] || positionStyles['top-right']);
|
15
23
|
}
|
16
24
|
|
17
25
|
const alertBox = document.createElement('div');
|
18
26
|
alertBox.className = `notification ${type}`;
|
19
|
-
alertBox.classList.add(position);
|
20
27
|
|
21
28
|
// Ícone
|
22
29
|
const icon = document.createElement('div');
|
@@ -29,7 +36,10 @@ const FlickerAlerts = {
|
|
29
36
|
}[type];
|
30
37
|
icon.innerHTML = `<i class="fas ${iconClass}" style="font-size: 24px;"></i>`;
|
31
38
|
alertBox.appendChild(icon);
|
32
|
-
|
39
|
+
const divider = document.createElement('div');
|
40
|
+
divider.className = 'divider';
|
41
|
+
alertBox.appendChild(divider);
|
42
|
+
|
33
43
|
// Conteúdo
|
34
44
|
const content = document.createElement('div');
|
35
45
|
content.innerHTML = `<div class="title">${title}</div><div class="message">${message}</div>`;
|
@@ -51,7 +61,9 @@ const FlickerAlerts = {
|
|
51
61
|
});
|
52
62
|
|
53
63
|
alertBox.appendChild(closeButton);
|
54
|
-
|
64
|
+
|
65
|
+
// Adiciona no contêiner
|
66
|
+
container.prepend(alertBox);
|
55
67
|
|
56
68
|
// Timeout para remover automaticamente o alerta
|
57
69
|
const timeoutId = setTimeout(() => {
|
@@ -67,7 +79,6 @@ const FlickerAlerts = {
|
|
67
79
|
};
|
68
80
|
|
69
81
|
|
70
|
-
|
71
82
|
// Botões de teste - Eles podem ser removidos se não forem necessários
|
72
83
|
if (typeof document !== 'undefined') {
|
73
84
|
document.getElementById('success-btn')?.addEventListener('click', () => {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "flicker-alerts",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.79",
|
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.78"
|
22
22
|
}
|
23
23
|
}
|
package/readme.md
CHANGED
@@ -51,7 +51,9 @@ FlickerAlerts.showAlert({
|
|
51
51
|
type: 'success', // 'success', 'info', 'warning', 'danger'
|
52
52
|
title: 'Sucesso!',
|
53
53
|
message: 'Operação realizada com sucesso.',
|
54
|
-
position: 'top-right', //
|
54
|
+
position: 'top-right', // Você pode usar qualquer uma das opções abaixo:
|
55
|
+
// 'top-right', 'top-left', 'bottom-right', 'bottom-left',
|
56
|
+
// 'center', 'top-center', 'bottom-center'
|
55
57
|
duration: 5000
|
56
58
|
});
|
57
59
|
```
|
@@ -156,7 +158,7 @@ Essa abordagem é recomendada para garantir que o estilo seja incluído no build
|
|
156
158
|
| `type` | `string` | Tipo do alerta: `success`, `info`, `warning`, `danger`. |
|
157
159
|
| `title` | `string` | Título do alerta. |
|
158
160
|
| `message` | `string` | Mensagem do alerta. |
|
159
|
-
| `position` | `string` |
|
161
|
+
| `position` | `string` |Posição: `top-right`, `top-left`, `bottom-right`, `bottom-left`, `center`, `top-center`, `bottom-center`.|
|
160
162
|
| `duration` | `number` | Duração do alerta em milissegundos. |
|
161
163
|
|
162
164
|
---
|
package/style.css
CHANGED
@@ -1,32 +1,76 @@
|
|
1
1
|
|
2
|
-
|
3
2
|
#alerts-container {
|
4
3
|
position: fixed;
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
height: 100vh;
|
9
|
-
pointer-events: none; /* Impede que o contêiner interfira nos cliques */
|
10
|
-
padding-right: 20px;
|
4
|
+
display: flex;
|
5
|
+
gap: 10px;
|
6
|
+
pointer-events: none;
|
11
7
|
}
|
12
8
|
|
13
|
-
|
14
9
|
.notification {
|
15
|
-
margin:
|
10
|
+
margin: 5px;
|
16
11
|
background-color: #ffffff;
|
12
|
+
border: 1px solid #ced4da;
|
13
|
+
box-shadow: 6px 6px 6px rgba(0, 0, 0, 0.1);
|
17
14
|
border-radius: 10px;
|
18
|
-
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
19
15
|
padding: 20px;
|
20
16
|
min-width: 300px;
|
21
17
|
max-width: 500px;
|
22
18
|
display: flex;
|
23
19
|
align-items: center;
|
24
|
-
position:
|
25
|
-
z-index: 9999; /* Garante que as notificações fiquem acima de outros elementos */
|
20
|
+
position: relative;
|
26
21
|
opacity: 1;
|
27
|
-
transition: opacity 0.3s ease-out;
|
28
|
-
pointer-events: auto;
|
22
|
+
transition: opacity 0.3s ease-out, transform 0.3s ease;
|
23
|
+
pointer-events: auto;
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
.notification .icon {
|
28
|
+
display: flex;
|
29
|
+
align-items: center;
|
30
|
+
justify-content: center;
|
31
|
+
font-size: 24px;
|
32
|
+
color: #5a5a5a;
|
33
|
+
margin-right: 10px;
|
34
|
+
}
|
35
|
+
|
36
|
+
.notification .divider {
|
37
|
+
width: 1px;
|
38
|
+
height: 40px;
|
39
|
+
background-color: #e0e0e0;
|
40
|
+
margin-right: 15px;
|
41
|
+
}
|
42
|
+
|
43
|
+
.notification .content {
|
44
|
+
display: flex;
|
45
|
+
flex-direction: column;
|
46
|
+
}
|
47
|
+
|
48
|
+
.notification .title {
|
49
|
+
font-weight: bold;
|
50
|
+
font-size: 16px;
|
51
|
+
margin-bottom: 5px;
|
52
|
+
color: #333;
|
29
53
|
}
|
54
|
+
|
55
|
+
.notification .message {
|
56
|
+
font-size: 14px;
|
57
|
+
color: #555;
|
58
|
+
}
|
59
|
+
|
60
|
+
|
61
|
+
.notification .close {
|
62
|
+
position: absolute;
|
63
|
+
top: 10px;
|
64
|
+
right: 10px;
|
65
|
+
cursor: pointer;
|
66
|
+
font-size: 16px;
|
67
|
+
color: #999;
|
68
|
+
}
|
69
|
+
|
70
|
+
.notification .close:hover {
|
71
|
+
color: #666;
|
72
|
+
}
|
73
|
+
|
30
74
|
.text-import{
|
31
75
|
color: rgb(255, 0, 85);
|
32
76
|
}
|
@@ -82,7 +126,7 @@ margin: 20px;
|
|
82
126
|
font-size: 16px;
|
83
127
|
}
|
84
128
|
|
85
|
-
|
129
|
+
|
86
130
|
.success .icon {
|
87
131
|
background-color: #28a745;
|
88
132
|
}
|
@@ -115,49 +159,55 @@ margin: 20px;
|
|
115
159
|
color: #ffc107;
|
116
160
|
}
|
117
161
|
|
118
|
-
|
162
|
+
|
119
163
|
.top-right {
|
120
164
|
top: 1rem;
|
121
165
|
right: 1rem;
|
166
|
+
flex-direction: column;
|
122
167
|
}
|
123
168
|
|
124
169
|
.top-left {
|
125
170
|
top: 1rem;
|
126
171
|
left: 1rem;
|
172
|
+
flex-direction: column;
|
127
173
|
}
|
128
174
|
|
129
175
|
.bottom-right {
|
130
176
|
bottom: 1rem;
|
131
177
|
right: 1rem;
|
178
|
+
flex-direction: column-reverse;
|
132
179
|
}
|
133
180
|
|
134
181
|
.bottom-left {
|
135
182
|
bottom: 1rem;
|
136
183
|
left: 1rem;
|
184
|
+
flex-direction: column-reverse;
|
137
185
|
}
|
138
186
|
|
139
187
|
.center {
|
140
188
|
top: 50%;
|
141
189
|
left: 50%;
|
142
190
|
transform: translate(-50%, -50%);
|
191
|
+
flex-direction: column;
|
143
192
|
}
|
144
193
|
|
145
194
|
.top-center {
|
146
195
|
top: 1rem;
|
147
196
|
left: 50%;
|
148
197
|
transform: translateX(-50%);
|
198
|
+
flex-direction: column;
|
149
199
|
}
|
150
200
|
|
151
|
-
.bottom-center {
|
201
|
+
.bottom-center {
|
152
202
|
bottom: 1rem;
|
153
203
|
left: 50%;
|
154
204
|
transform: translateX(-50%);
|
205
|
+
flex-direction: column-reverse;
|
155
206
|
}
|
156
207
|
|
157
208
|
|
158
209
|
|
159
210
|
|
160
|
-
/* Barra de carregamento */
|
161
211
|
.notification .progress-bar {
|
162
212
|
position: absolute;
|
163
213
|
bottom: 0;
|
@@ -170,7 +220,7 @@ margin: 20px;
|
|
170
220
|
border-bottom-right-radius: 10px;
|
171
221
|
}
|
172
222
|
|
173
|
-
|
223
|
+
|
174
224
|
@keyframes progress-animation {
|
175
225
|
from {
|
176
226
|
width: 0%;
|
@@ -180,7 +230,7 @@ margin: 20px;
|
|
180
230
|
}
|
181
231
|
}
|
182
232
|
|
183
|
-
|
233
|
+
|
184
234
|
.success .progress-bar {
|
185
235
|
background-color: #28a745;
|
186
236
|
}
|
@@ -200,20 +250,20 @@ margin: 20px;
|
|
200
250
|
|
201
251
|
|
202
252
|
|
203
|
-
|
253
|
+
|
204
254
|
|
205
255
|
.modal-container {
|
206
|
-
|
256
|
+
|
207
257
|
display: flex;
|
208
|
-
justify-content: center;
|
209
|
-
align-items: center;
|
210
|
-
position: fixed;
|
211
|
-
top: 0;
|
212
|
-
left: 0;
|
213
|
-
width: 100vw;
|
214
|
-
height: 100vh;
|
258
|
+
justify-content: center;
|
259
|
+
align-items: center;
|
260
|
+
position: fixed;
|
261
|
+
top: 0;
|
262
|
+
left: 0;
|
263
|
+
width: 100vw;
|
264
|
+
height: 100vh;
|
215
265
|
margin: 0;
|
216
|
-
z-index: 9999;
|
266
|
+
z-index: 9999;
|
217
267
|
}
|
218
268
|
|
219
269
|
.modal-dialog {
|
@@ -224,8 +274,9 @@ margin: 20px;
|
|
224
274
|
background-color: white;
|
225
275
|
border-radius: 10px;
|
226
276
|
padding: 20px;
|
227
|
-
border:
|
228
|
-
box-shadow:
|
277
|
+
border: 1px solid #ced4da;
|
278
|
+
box-shadow: 6px 6px 6px rgba(0, 0, 0, 0.1);
|
279
|
+
|
229
280
|
}
|
230
281
|
.modal-header {
|
231
282
|
border-bottom: none;
|