flicker-alerts 1.0.7 → 1.0.9

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.
Files changed (3) hide show
  1. package/index.js +11 -4
  2. package/package.json +3 -2
  3. package/style.css +5 -0
package/index.js CHANGED
@@ -2,6 +2,16 @@ const FlickerAlerts = {
2
2
  showAlert: function ({ type, title, message, timer = 3000 }) {
3
3
  // Verifique se está no ambiente do navegador (client-side) antes de tentar manipular o DOM
4
4
  if (typeof window !== 'undefined' && typeof document !== 'undefined') {
5
+ // Garantir que o container de alertas exista, se não, criá-lo
6
+ let container = document.getElementById('alerts-container');
7
+ if (!container) {
8
+ // Cria o container se ele não existir
9
+ container = document.createElement('div');
10
+ container.id = 'alerts-container';
11
+ container.className = 'top-right'; // Aplica a classe para posicionar no topo direito
12
+ document.body.appendChild(container); // Adiciona o container ao body
13
+ }
14
+
5
15
  // Criação do alerta
6
16
  const alertBox = document.createElement('div');
7
17
  alertBox.className = `alert-custom alert-${type}`;
@@ -36,10 +46,7 @@ const FlickerAlerts = {
36
46
  alertBox.appendChild(progressBar);
37
47
 
38
48
  // Adicionar ao container
39
- const container = document.getElementById('alerts-container');
40
- if (container) {
41
- container.appendChild(alertBox);
42
- }
49
+ container.appendChild(alertBox);
43
50
 
44
51
  // Remoção automática após o tempo especificado
45
52
  setTimeout(() => alertBox.remove(), timer);
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "flicker-alerts",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Biblioteca para alertas animados",
5
5
  "main": "index.js",
6
- "types": "index.d.ts",
6
+ "types": "index.d.ts",
7
+ "style": "style.css",
7
8
  "scripts": {
8
9
  "test": "echo \"Error: no test specified\" && exit 1"
9
10
  },
package/style.css CHANGED
@@ -1,3 +1,4 @@
1
+ /* Estilo geral para o alerta */
1
2
  .alert-custom {
2
3
  display: flex;
3
4
  align-items: center;
@@ -67,6 +68,7 @@
67
68
  color: #777; /* Cor mais escura no hover */
68
69
  }
69
70
 
71
+ /* Estilos para os tipos de alerta */
70
72
  .alert-success {
71
73
  border-left: 0.25rem solid #28a745;
72
74
  }
@@ -103,6 +105,7 @@
103
105
  color: white;
104
106
  }
105
107
 
108
+ /* Classe para o container de alertas no topo direito */
106
109
  .top-right {
107
110
  position: fixed;
108
111
  top: 1rem;
@@ -113,6 +116,7 @@
113
116
  z-index: 1050;
114
117
  }
115
118
 
119
+ /* Barra de progresso */
116
120
  .progress-bar {
117
121
  position: absolute;
118
122
  bottom: 0;
@@ -138,6 +142,7 @@
138
142
  background-color: #dc3545;
139
143
  }
140
144
 
145
+ /* Animação de progresso */
141
146
  @keyframes load {
142
147
  from {
143
148
  width: 0;