Skip to content

Commit 33ed303

Browse files
committed
Update draft
1 parent f50578d commit 33ed303

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

public/sw.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const cacheName = "cache2";
1+
const cacheName = "cache7";
22

33
self.addEventListener("install", (event) => {
44
self.skipWaiting();
@@ -9,6 +9,8 @@ self.addEventListener("install", (event) => {
99
"/",
1010
"favicon.ico",
1111
"index.html",
12+
"schedule/talks/index.html",
13+
"schedule/speakers/index.html",
1214
"main.js",
1315
"manifest.json",
1416
"style.css",

src/components/Offline.astro

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
---
2+
3+
---
4+
<div id="offline-icon" class="offline-icon">
5+
<i class="fas plug-circle-xmark"></i> Offline
6+
</div>
7+
<script is:inline>
8+
9+
document.addEventListener('DOMContentLoaded', () => {
10+
const offlineIcon = document.getElementById('offline-icon');
11+
12+
function updateOnlineStatus() {
13+
console.log('offline');
14+
offlineIcon.classList.toggle('show', !navigator.onLine);
15+
}
16+
17+
window.addEventListener('online', updateOnlineStatus);
18+
window.addEventListener('offline', updateOnlineStatus);
19+
20+
// Initial check
21+
updateOnlineStatus();
22+
}
23+
);
24+
</script>
25+
26+
<style>
27+
.offline-icon {
28+
position: fixed;
29+
bottom: 10px;
30+
right: 10px;
31+
z-index: 9999;
32+
background: #ffe0e0;
33+
color: #a00;
34+
padding: 8px 12px;
35+
border-radius: 8px;
36+
border: 1px solid #a00;
37+
font-family: sans-serif;
38+
font-size: 14px;
39+
font-weight: bold;
40+
display: flex;
41+
align-items: center;
42+
gap: 6px;
43+
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
44+
opacity: 0;
45+
pointer-events: none;
46+
transition: opacity 0.3s ease;
47+
}
48+
49+
.offline-icon.show {
50+
opacity: 1;
51+
pointer-events: auto;
52+
}
53+
</style>

src/layouts/Layout.astro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import BaseHead from "@components/BaseHead.astro";
33
import Header from "@components/Header.astro";
44
import Footer from "@components/Footer.astro";
5-
5+
import Offline from "@components/Offline.astro";
66
77
import "@src/styles/global.css";
88
import "@src/styles/search.css";
@@ -33,21 +33,21 @@ const externalDomain = new URL(Astro.site || "").hostname;
3333
<meta name="theme-color" content="#6200ee" />
3434
<link rel="apple-touch-icon" href="/icons/icon-192x192.png" />
3535
</Fragment>
36-
36+
</head>
3737
<body>
3838
<header>
3939
<Header />
4040
</header>
4141

4242
<main class="main pt-28" role="main">
43+
<Offline />
4344
<slot />
4445
</main>
4546

4647
<footer>
4748
<Footer />
4849
</footer>
4950

50-
5151
</body>
5252
</html>
5353

0 commit comments

Comments
 (0)