Skip to content

Commit

Permalink
feat: PWA test
Browse files Browse the repository at this point in the history
Signed-off-by: Colton Wolkins (Laptop) <colton@indicio.tech>
  • Loading branch information
TheTechmage committed Mar 17, 2024
1 parent cd74dcc commit da5d0f2
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 0 deletions.
35 changes: 35 additions & 0 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"short_name": "Wyvern",
"name": "Wyvern: Where communities thrive~",
"display": "standalone",
"display_override": ["window-controls-overlay"],
"theme_color": "#3367D6",
"start_url": "/wyvern/",
"icons": [
{
"src": "/pwa/icons-vector.svg",
"type": "image/svg+xml",
"sizes": "512x512"
}
],
"id": "/wyvern/?source=pwa",
"background_color": "#3367D6",
"scope": "/wyvern/",
"shortcuts": [
{
"name": "How's the weather today?",
"short_name": "Today",
"description": "View weather information for today",
"url": "/wyvern/today?source=pwa",
"icons": [{ "src": "/wyvern/images/today.png", "sizes": "192x192" }]
},
{
"name": "How's the weather tomorrow?",
"short_name": "Tomorrow",
"description": "View weather information for tomorrow",
"url": "/wyvern/tomorrow?source=pwa",
"icons": [{ "src": "/wyvern/images/tomorrow.png", "sizes": "192x192" }]
}
],
"description": "Weather forecast information"
}
13 changes: 13 additions & 0 deletions public/pwa-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Initialize deferredPrompt for use later to show browser install prompt.
let deferredPrompt;

window.addEventListener('beforeinstallprompt', (e) => {
// Prevent the mini-infobar from appearing on mobile
e.preventDefault();
// Stash the event so it can be triggered later.
deferredPrompt = e;
// Update UI notify the user they can install the PWA
showInstallPromotion();
// Optionally, send analytics event that PWA install promo was shown.
console.log(`'beforeinstallprompt' event was fired.`);
});
3 changes: 3 additions & 0 deletions public/pwa/icons-vector.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ export default function RootLayout({
}>) {
return (
<html lang="en">
<head>
<link rel="manifest" href="/manifest.json" />
<script src="/pwa-script.js" />
</head>
<body className={inter.className}>{children}</body>
</html>
);
Expand Down

0 comments on commit da5d0f2

Please sign in to comment.