-
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
11 changed files
with
252 additions
and
25 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,20 +1,74 @@ | ||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 736px; | ||
margin: 1rem auto 5rem ; | ||
padding: 0 1rem; | ||
} | ||
.content mat-card-content { | ||
line-height: 1.5; | ||
} | ||
|
||
.content blockquote { | ||
position: relative; | ||
font-style: italic; | ||
} | ||
|
||
.content blockquote:before { | ||
content: open-quote; | ||
position: absolute; | ||
top: -1rem; | ||
left: -2rem; | ||
font-size: 4rem; | ||
line-height: 5rem; | ||
font-weight: lighter; | ||
color: rgba(0, 0, 0, .77) | ||
} | ||
|
||
.toolbar-icon { | ||
padding: 0 14px; | ||
} | ||
|
||
.toolbar-spacer { | ||
flex: 1 1 auto; | ||
} | ||
|
||
.pwa-install-panel { | ||
position: fixed; | ||
bottom: 0; | ||
width: 100%; | ||
box-shadow: 0px -3px 5px -1px rgba(0, 0, 0, 0.2), | ||
0px -5px 8px 0px rgba(0, 0, 0, 0.14), | ||
0px -1px 14px 0px rgba(0, 0, 0, 0.12); | ||
background: #eeeaea; | ||
color: #3e3e3e; | ||
padding: 1.5rem; | ||
user-select: none; | ||
text-align: center; | ||
transition: all ease-out .2s; | ||
} | ||
.pwa-install-panel:hover { | ||
box-shadow: 0px -5px 5px -1px rgba(0, 0, 0, 0.2), | ||
0px -7px 8px 0px rgba(0, 0, 0, 0.14), | ||
0px -3px 14px 0px rgba(0, 0, 0, 0.12); | ||
transform: translateY(-1px); | ||
padding: 1rem; | ||
} | ||
|
||
.pwa-install-panel mat-card { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: baseline; | ||
text-transform: uppercase; | ||
} | ||
.pwa-install-panel mat-card-actions { | ||
display: flex; | ||
justify-content: flex-start; | ||
} | ||
@media (max-width: 736px) { | ||
.pwa-install-panel mat-card { | ||
flex-direction: column; | ||
align-items: stretch; | ||
} | ||
} | ||
|
||
.logo { | ||
background: url("../assets/pwa.png") no-repeat center; | ||
background-size: contain; | ||
border-radius: 0; | ||
} | ||
|
||
.logo img { | ||
width: 100%; | ||
} | ||
|
||
pre { | ||
margin: 0; | ||
white-space: pre-wrap; | ||
} |
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 |
---|---|---|
@@ -1,3 +1,95 @@ | ||
<mat-toolbar color="primary"> | ||
NgxPwaInstall | ||
<span class="toolbar-spacer"></span> | ||
<a href="https://github.com/alQlagin/ngx-pwa-install" mat-button target="_blank"> | ||
<img src="assets/github-circle-white-transparent.svg"> <span class="mat-body-1">GitHub</span> | ||
</a> | ||
</mat-toolbar> | ||
<div class="content"> | ||
<mat-card> | ||
<mat-card-header> | ||
<div mat-card-avatar class="logo"></div> | ||
<mat-card-title>Progressive web app</mat-card-title> | ||
<mat-card-subtitle>Add to Home Screen</mat-card-subtitle> | ||
</mat-card-header> | ||
<mat-card-content> | ||
<blockquote> | ||
<p> | ||
Add to Home Screen, sometimes referred to as the web app install prompt, makes it easy for users to install | ||
your | ||
Progressive Web App on their mobile or desktop device. After the user accepts the prompt, your PWA will be | ||
added | ||
to their launcher, and it will run like any other installed app. | ||
</p> | ||
<p> | ||
Chrome handles most of the heavy lifting for you: | ||
</p> | ||
<ul> | ||
<li>On mobile, Chrome will generate a WebAPK, creating an even more integrated experience for your users.</li> | ||
<li>On desktop, your app will installed, and run in an app window.</li> | ||
</ul> | ||
<p> | ||
In order for a user to be able to install your Progressive Web App, it needs to meet the | ||
<a class="mat-accent" href="https://developers.google.com/web/fundamentals/app-install-banners#criteria" | ||
target="_blank">following | ||
criteria</a> | ||
</p> | ||
</blockquote> | ||
</mat-card-content> | ||
<mat-card-content> | ||
<p class="mat-title"> | ||
Show the Add to Home Screen dialog | ||
</p> | ||
<p> | ||
In order to show the Add to Home Screen dialog, you need to: | ||
</p> | ||
<ol> | ||
<li>Listen for the beforeinstallprompt event</li> | ||
<li>Notify the user your app can be installed with a button or other element that will generate a user gesture | ||
event. | ||
</li> | ||
<li>Show the prompt by calling prompt() on the saved beforeinstallprompt event</li> | ||
</ol> | ||
</mat-card-content> | ||
<mat-card-content> | ||
<p class="mat-title">Listen for beforeinstallprompt</p> | ||
<p> | ||
<a href="https://www.npmjs.com/package/ngx-pwa-install" target="_blank">NgxPwaInstall</a> handles | ||
beforeinstallprompt on startup and allows to display install panel at any place | ||
</p> | ||
<p> | ||
To setup NgxPwaInstallinstall it with | ||
</p> | ||
<pre> | ||
npm install ngx-pwa-install | ||
</pre> | ||
and add to your AppModule | ||
<pre>{{installExampleText}}</pre> | ||
<p>Later you can wrap pwa install panes with | ||
<strong style="white-space: nowrap"><ngx-pwa-install #pwa></ngx-pwa-install></strong> | ||
</p> | ||
<pre>{{panelExampleText}}</pre> | ||
<p>You just need to call <strong>pwa.install()</strong> when user ready to install</p> | ||
<p> | ||
This will call | ||
<a href="https://developers.google.com/web/fundamentals/app-install-banners#show_the_prompt" target="_blank"> | ||
prompt | ||
</a> | ||
on the saved event. It will show a modal dialog, asking the user to to add your app to their home screen. | ||
</p> | ||
</mat-card-content> | ||
</mat-card> | ||
</div> | ||
<ngx-pwa-install #pwa> | ||
<div @installPwa class="pwa-install-panel" (click)="pwa.install()">Install me</div> | ||
<div @installPwa class="pwa-install-panel" *ngIf="!dismissed"> | ||
<mat-card class="mat-elevation-z5"> | ||
<mat-card-content> | ||
You can install this application to your device | ||
</mat-card-content> | ||
<mat-card-actions> | ||
<button mat-raised-button color="primary" (click)="pwa.install()">INSTALL</button> | ||
<button mat-button (click)="dismiss()">DISMISS</button> | ||
</mat-card-actions> | ||
</mat-card> | ||
</div> | ||
</ngx-pwa-install> |
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
1 change: 1 addition & 0 deletions
1
projects/ngx-pwa-install-demo/src/assets/github-circle-white-transparent.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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