-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
441 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,9 +24,10 @@ | |
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
<title>Note Saver</title> | ||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" | ||
rel="stylesheet"> | ||
<script src="https://unpkg.com/[email protected]/dist/ionicons.js"></script> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
|
@@ -41,5 +42,14 @@ | |
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
<script> | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', () => { | ||
navigator.serviceWorker.register('%PUBLIC_URL%/worker.js') | ||
.then(reg => console.log(`Registered successfully with scope: ${reg.scope}`)) | ||
.catch(err => console.log(`Service worker error: ${err}`)); | ||
}); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Oops!</title> | ||
</head> | ||
<body> | ||
<p>Please go online to see, save or delete your note.</p> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* eslint-disable no-restricted-globals */ | ||
const OFFLINE_VERSION = 1; | ||
const CACHE_NAME = 'offline'; | ||
// Customize this with a different URL if needed. | ||
const OFFLINE_URL = 'offline.html'; | ||
|
||
self.addEventListener('install', (event) => { | ||
event.waitUntil((async () => { | ||
const cache = await caches.open(CACHE_NAME); | ||
// Setting {cache: 'reload'} in the new request will ensure that the response | ||
// isn't fulfilled from the HTTP cache; i.e., it will be from the network. | ||
await cache.add(new Request(OFFLINE_URL, {cache: 'reload'})); | ||
})()); | ||
}); | ||
|
||
self.addEventListener('activate', (event) => { | ||
event.waitUntil((async () => { | ||
// Enable navigation preload if it's supported. | ||
// See https://developers.google.com/web/updates/2017/02/navigation-preload | ||
if ('navigationPreload' in self.registration) { | ||
await self.registration.navigationPreload.enable(); | ||
} | ||
})()); | ||
|
||
// Tell the active service worker to take control of the page immediately. | ||
self.clients.claim(); | ||
}); | ||
|
||
self.addEventListener('fetch', (event) => { | ||
// We only want to call event.respondWith() if this is a navigation request | ||
// for an HTML page. | ||
if (event.request.mode === 'navigate') { | ||
event.respondWith((async () => { | ||
try { | ||
// First, try to use the navigation preload response if it's supported. | ||
const preloadResponse = await event.preloadResponse; | ||
if (preloadResponse) { | ||
return preloadResponse; | ||
} | ||
|
||
const networkResponse = await fetch(event.request); | ||
return networkResponse; | ||
} catch (error) { | ||
// catch is only triggered if an exception is thrown, which is likely | ||
// due to a network error. | ||
// If fetch() returns a valid HTTP response with a response code in | ||
// the 4xx or 5xx range, the catch() will NOT be called. | ||
console.log('Fetch failed; returning offline page instead.', error); | ||
|
||
const cache = await caches.open(CACHE_NAME); | ||
const cachedResponse = await cache.match(OFFLINE_URL); | ||
return cachedResponse; | ||
} | ||
})()); | ||
} | ||
|
||
// If our if() condition is false, then this fetch handler won't intercept the | ||
// request. If there are any other fetch handlers registered, they will get a | ||
// chance to call event.respondWith(). If no fetch handlers call | ||
// event.respondWith(), the request will be handled by the browser as if there | ||
// were no service worker involvement. | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const MAIN_COLOR = `#111c33`; | ||
export const TEXT_COLOR = `#1ecbe1`; | ||
export const MAIN_COLOR_LIGHT = `#223861`; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.