Skip to content

Commit 493ba4c

Browse files
committed
Add pwa support for "desktop installation"
- Icons must be updated with another theme color, re-using wallet icons.
1 parent 7e7b187 commit 493ba4c

14 files changed

+132
-11
lines changed

angular.json

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@
2727
"inlineStyleLanguage": "scss",
2828
"assets": [
2929
"src/favicon.ico",
30-
"src/assets"
30+
"src/assets",
31+
"src/manifest.webmanifest"
3132
],
3233
"styles": [
3334
"src/styles.scss"
3435
],
35-
"scripts": []
36+
"scripts": [],
37+
"serviceWorker": true,
38+
"ngswConfigPath": "ngsw-config.json"
3639
},
3740
"configurations": {
3841
"production": {
@@ -90,7 +93,8 @@
9093
"inlineStyleLanguage": "scss",
9194
"assets": [
9295
"src/favicon.ico",
93-
"src/assets"
96+
"src/assets",
97+
"src/manifest.webmanifest"
9498
],
9599
"styles": [
96100
"src/styles.scss"

ngsw-config.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
3+
"index": "/index.html",
4+
"assetGroups": [
5+
{
6+
"name": "app",
7+
"installMode": "prefetch",
8+
"resources": {
9+
"files": [
10+
"/favicon.ico",
11+
"/index.html",
12+
"/manifest.webmanifest",
13+
"/*.css",
14+
"/*.js"
15+
]
16+
}
17+
},
18+
{
19+
"name": "assets",
20+
"installMode": "lazy",
21+
"updateMode": "prefetch",
22+
"resources": {
23+
"files": [
24+
"/assets/**",
25+
"/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
26+
]
27+
}
28+
}
29+
]
30+
}

package-lock.json

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"@angular/platform-browser": "^15.0.0",
2323
"@angular/platform-browser-dynamic": "^15.0.0",
2424
"@angular/router": "^15.0.0",
25+
"@angular/service-worker": "^15.0.0",
2526
"rxjs": "~7.5.0",
2627
"tslib": "^2.3.0",
2728
"zone.js": "~0.12.0"

src/app/app.module.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { NgModule } from '@angular/core';
1+
import { NgModule, isDevMode } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
33

44
import { AppRoutingModule } from './app-routing.module';
55
import { AppComponent } from './app.component';
66
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7+
import { ServiceWorkerModule } from '@angular/service-worker';
78

89
@NgModule({
910
declarations: [
@@ -12,7 +13,13 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
1213
imports: [
1314
BrowserModule,
1415
AppRoutingModule,
15-
BrowserAnimationsModule
16+
BrowserAnimationsModule,
17+
ServiceWorkerModule.register('ngsw-worker.js', {
18+
enabled: !isDevMode(),
19+
// Register the ServiceWorker as soon as the application is stable
20+
// or after 30 seconds (whichever comes first).
21+
registrationStrategy: 'registerWhenStable:30000'
22+
})
1623
],
1724
providers: [],
1825
bootstrap: [AppComponent]

src/assets/icons/icon-128x128.png

6.94 KB
Loading

src/assets/icons/icon-16x16.png

2.16 KB
Loading

src/assets/icons/icon-2048x2048.png

127 KB
Loading

src/assets/icons/icon-256x256.png

12.2 KB
Loading

src/assets/icons/icon-32x32.png

2.9 KB
Loading

src/assets/icons/icon-48x48.png

3.72 KB
Loading

src/assets/icons/icon-512x512.png

25 KB
Loading

src/index.html

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<meta charset="utf-8" />
4+
<meta charset="utf-8"/>
55
<title>Blockcore Notes - Share notes on nostr protocol</title>
6-
<base href="/" />
7-
<meta name="viewport" content="width=device-width, initial-scale=1" />
8-
<link rel="icon" type="image/x-icon" href="favicon.ico" />
6+
<base href="/"/>
7+
<meta name="viewport" content="width=device-width, initial-scale=1"/>
8+
<link rel="icon" type="image/x-icon" href="favicon.ico"/>
99
<style>
1010
.loading-text {
1111
text-align: center;
1212
padding-top: 4em;
1313
}
1414
</style>
1515
<link rel="preconnect" href="https://fonts.gstatic.com">
16-
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
16+
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap" rel="stylesheet">
1717
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
18+
<link rel="manifest" href="manifest.webmanifest">
19+
<meta name="theme-color" content="#1976d2">
1820
</head>
1921
<body class="mat-typography">
2022
<app-root><div class="loading-text">Blockcore loading...</div></app-root>
21-
</body>
23+
<noscript>Please enable JavaScript to continue using this application.</noscript>
24+
</body>
2225
</html>

src/manifest.webmanifest

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
{
2+
"name": "Blockcore Notes",
3+
"short_name": "Notes",
4+
"author": "Blockcore",
5+
"theme_color": "#22a893",
6+
"background_color": "#212121",
7+
"display": "standalone",
8+
"scope": "./",
9+
"start_url": "./",
10+
"icons": [
11+
{
12+
"src": "assets/icons/icon-32x32.png",
13+
"sizes": "32x32",
14+
"type": "image/png",
15+
"purpose": "maskable any"
16+
},
17+
{
18+
"src": "assets/icons/icon-48x48.png",
19+
"sizes": "48x48",
20+
"type": "image/png",
21+
"purpose": "maskable any"
22+
},
23+
{
24+
"src": "assets/icons/icon-128x128.png",
25+
"sizes": "128x128",
26+
"type": "image/png",
27+
"purpose": "maskable any"
28+
},
29+
{
30+
"src": "assets/icons/icon-256x256.png",
31+
"sizes": "256x256",
32+
"type": "image/png",
33+
"purpose": "maskable any"
34+
},
35+
{
36+
"src": "assets/icons/icon-512x512.png",
37+
"sizes": "512x512",
38+
"type": "image/png",
39+
"purpose": "maskable any"
40+
},
41+
{
42+
"src": "assets/icons/icon-2048x2048.png",
43+
"sizes": "2048x2048",
44+
"type": "image/png",
45+
"purpose": "maskable any"
46+
}
47+
],
48+
"categories": ["productivity"]
49+
}

0 commit comments

Comments
 (0)