Skip to content

Commit 22c9c22

Browse files
committed
Online and offline state
1 parent 5a29c24 commit 22c9c22

File tree

4 files changed

+30
-4
lines changed

4 files changed

+30
-4
lines changed

packages/test-app/Todo.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Todos
2+
3+
* offline, online indicator
4+
* info page with
5+
* info
6+
* todo
7+
* Changelog
8+
* Privacy policy

packages/test-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"etherscan-api": "^8.1.2",
2020
"express": "^4.16.3",
2121
"polymer-cli": "^1.7.3",
22-
"prpl-server": "^1.2.0"
22+
"prpl-server": "^1.2.0",
23+
"pwa-helpers": "^0.8.2"
2324
},
2425
"scripts": {
2526
"test": "npm run build",

packages/test-app/src/test-app-app/svg-sample-icons.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ $_documentContainer.innerHTML = `<iron-iconset-svg name="svg-sample-icons" size=
2929
<g id="cart">
3030
<svg style="width:24px;height:24px" viewBox="0 0 24 24">
3131
<path fill="#000000" d="M11,9H13V6H16V4H13V1H11V4H8V6H11M7,18A2,2 0 0,0 5,20A2,2 0 0,0 7,22A2,2 0 0,0 9,20A2,2 0 0,0 7,18M17,18A2,2 0 0,0 15,20A2,2 0 0,0 17,22A2,2 0 0,0 19,20A2,2 0 0,0 17,18M7.17,14.75L7.2,14.63L8.1,13H15.55C16.3,13 16.96,12.59 17.3,11.97L21.16,4.96L19.42,4H19.41L18.31,6L15.55,11H8.53L8.4,10.73L6.16,6L5.21,4L4.27,2H1V4H3L6.6,11.59L5.25,14.04C5.09,14.32 5,14.65 5,15A2,2 0 0,0 7,17H19V15H7.42C7.29,15 7.17,14.89 7.17,14.75Z" />
32+
</svg>
33+
</g>
34+
<g id="online-status">
35+
<svg style="width:24px;height:24px" viewBox="0 0 24 24">
36+
<path fill="#000000" d="M4.93,4.93C3.12,6.74 2,9.24 2,12C2,14.76 3.12,17.26 4.93,19.07L6.34,17.66C4.89,16.22 4,14.22 4,12C4,9.79 4.89,7.78 6.34,6.34L4.93,4.93M19.07,4.93L17.66,6.34C19.11,7.78 20,9.79 20,12C20,14.22 19.11,16.22 17.66,17.66L19.07,19.07C20.88,17.26 22,14.76 22,12C22,9.24 20.88,6.74 19.07,4.93M7.76,7.76C6.67,8.85 6,10.35 6,12C6,13.65 6.67,15.15 7.76,16.24L9.17,14.83C8.45,14.11 8,13.11 8,12C8,10.89 8.45,9.89 9.17,9.17L7.76,7.76M16.24,7.76L14.83,9.17C15.55,9.89 16,10.89 16,12C16,13.11 15.55,14.11 14.83,14.83L16.24,16.24C17.33,15.15 18,13.65 18,12C18,10.35 17.33,8.85 16.24,7.76M12,10A2,2 0 0,0 10,12A2,2 0 0,0 12,14A2,2 0 0,0 14,12A2,2 0 0,0 12,10Z" />
3237
</svg>
3338
</g>
3439
</defs>

packages/test-app/src/test-app-app/test-app-app.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import '@polymer/paper-icon-button/paper-icon-button.js'
1717
import '@polymer/paper-button/paper-button.js';
1818
import '@polymer/paper-checkbox/paper-checkbox.js';
1919
import './svg-sample-icons.js'
20+
import { installOfflineWatcher } from 'pwa-helpers/network.js';
2021
/**
2122
* @customElement
2223
* @polymer
@@ -35,6 +36,9 @@ class TestAppApp extends PolymerElement {
3536
color: green;
3637
}
3738
39+
#statusicon[disabled], statusicon[disabled="disabled"] {
40+
border: 1px solid red;
41+
}
3842
body {
3943
margin: 0px;
4044
}
@@ -54,7 +58,9 @@ class TestAppApp extends PolymerElement {
5458
<app-header fixed condenses effects="waterfall" slot="header">
5559
<app-toolbar>
5660
<paper-icon-button icon="svg-sample-icons:info" on-tap="_openInfo"></paper-icon-button>
57-
<div main-title>Token Explorer</div>
61+
<paper-icon-button id="statusicon" icon="svg-sample-icons:online-status"></paper-icon-button>
62+
63+
<div main-title>Token Explorer</div>
5864
<paper-icon-button icon="svg-sample-icons:cart" on-tap="_openBuy"></paper-icon-button>
5965
<iron-dropdown id="buy" horizontal-align="right" vertical-align="top">
6066
<div slot="dropdown-content">
@@ -107,6 +113,14 @@ class TestAppApp extends PolymerElement {
107113
ready() {
108114
super.ready();
109115
this._triggerTokenSupply(this.tokens[0]);
116+
installOfflineWatcher((offline) => {
117+
118+
if (offline) {
119+
this.$.statusicon.setAttribute('disabled', true);
120+
} else {
121+
this.$.statusicon.removeAttribute('disabled');
122+
}
123+
})
110124
}
111125

112126
_openSettings() {
@@ -151,9 +165,7 @@ class TestAppApp extends PolymerElement {
151165
ga('send', 'event', 'history', token.name, this.durations[this.duration], {
152166
nonInteraction: false
153167
});
154-
console.log('send', 'event', 'history', token.name, this.durations[this.duration])
155168
}
156-
157169

158170
fetch(url)
159171
.then(function(response) {

0 commit comments

Comments
 (0)