create-walpole-ar 2.1.1 → 2.1.2
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/package.json +1 -1
- package/template/index.html +6 -0
- package/template/manifest.json +1 -1
- package/template/script.js +35 -0
- package/template/style.css +35 -0
- package/template/sw,js +1 -1
package/package.json
CHANGED
package/template/index.html
CHANGED
|
@@ -4,13 +4,19 @@
|
|
|
4
4
|
<meta charset="UTF-8">
|
|
5
5
|
<title>{{projectName}}</title>
|
|
6
6
|
<link rel="manifest" href="manifest.json">
|
|
7
|
+
<link rel="stylesheet" href="style.css">
|
|
7
8
|
</head>
|
|
8
9
|
<body>
|
|
10
|
+
<!-- index.html -->
|
|
11
|
+
<div id="statusIndicator" class="status-circle"></div>
|
|
9
12
|
<h1>Bienvenido a {{projectName}}</h1>
|
|
13
|
+
<!-- index.html -->
|
|
14
|
+
<button id="btnInstallApp" class="btn-install-pwa">Instalar App</button>
|
|
10
15
|
<script>
|
|
11
16
|
if ("serviceWorker" in navigator) {
|
|
12
17
|
navigator.serviceWorker.register("sw.js");
|
|
13
18
|
}
|
|
14
19
|
</script>
|
|
20
|
+
<script type="module" src="script.js"></script>
|
|
15
21
|
</body>
|
|
16
22
|
</html>
|
package/template/manifest.json
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// script.js
|
|
2
|
+
let deferredPrompt;
|
|
3
|
+
const installBtn = document.getElementById('btnInstallApp');
|
|
4
|
+
|
|
5
|
+
window.addEventListener('beforeinstallprompt', (e) => {
|
|
6
|
+
e.preventDefault();
|
|
7
|
+
deferredPrompt = e;
|
|
8
|
+
installBtn.style.display = 'inline-flex';
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
installBtn.addEventListener('click', async () => {
|
|
12
|
+
if(deferredPrompt){
|
|
13
|
+
deferredPrompt.prompt();
|
|
14
|
+
const { outcome } = await deferredPrompt.userChoice;
|
|
15
|
+
deferredPrompt = null;
|
|
16
|
+
if(outcome === 'accepted') installBtn.style.display = 'none';
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
// script.js
|
|
20
|
+
const statusCircle = document.getElementById('statusIndicator');
|
|
21
|
+
|
|
22
|
+
function updateOnlineStatus() {
|
|
23
|
+
if(navigator.onLine) {
|
|
24
|
+
statusCircle.classList.remove('offline');
|
|
25
|
+
} else {
|
|
26
|
+
statusCircle.classList.add('offline');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Escuchar cambios en la conexión
|
|
31
|
+
window.addEventListener('online', updateOnlineStatus);
|
|
32
|
+
window.addEventListener('offline', updateOnlineStatus);
|
|
33
|
+
|
|
34
|
+
// Estado inicial
|
|
35
|
+
updateOnlineStatus();
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/* estilo.css */
|
|
2
|
+
.btn-install-pwa {
|
|
3
|
+
background: linear-gradient(45deg,#4CAF50,#2E7D32); /* verde inicial */
|
|
4
|
+
color:white;
|
|
5
|
+
border:none;
|
|
6
|
+
padding:12px 25px;
|
|
7
|
+
border-radius:50px;
|
|
8
|
+
font-weight:700;
|
|
9
|
+
box-shadow:0 4px 15px rgba(0,0,0,0.2);
|
|
10
|
+
display:inline-flex;
|
|
11
|
+
align-items:center;
|
|
12
|
+
gap:10px;
|
|
13
|
+
transition: all 0.3s ease;
|
|
14
|
+
}
|
|
15
|
+
.btn-install-pwa:hover {
|
|
16
|
+
transform: translateY(-3px);
|
|
17
|
+
box-shadow:0 6px 18px rgba(0,0,0,0.3);
|
|
18
|
+
}
|
|
19
|
+
.btn-install-pwa.disabled {
|
|
20
|
+
background: #B71C1C; /* rojo cuando no se puede instalar */
|
|
21
|
+
cursor: not-allowed;
|
|
22
|
+
opacity:0.8;
|
|
23
|
+
}
|
|
24
|
+
/* estilo.css */
|
|
25
|
+
.status-circle {
|
|
26
|
+
width:20px;
|
|
27
|
+
height:20px;
|
|
28
|
+
border-radius:50%;
|
|
29
|
+
background-color:#4CAF50; /* verde = conectado */
|
|
30
|
+
border:2px solid #000;
|
|
31
|
+
transition: background-color 0.3s ease;
|
|
32
|
+
}
|
|
33
|
+
.status-circle.offline {
|
|
34
|
+
background-color:#F44336; /* rojo = sin conexión */
|
|
35
|
+
}
|
package/template/sw,js
CHANGED