Skip to content

Commit 6453dc8

Browse files
committed
Hide install header on click
1 parent c34b8c5 commit 6453dc8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pwa-template/index.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
</header>
6666
<iframe id="wp"></iframe>
6767
<script type="module" async>
68+
const slug = "{{PWA_SLUG}}";
69+
6870
/**
6971
* Install PWA button
7072
*/
@@ -75,7 +77,11 @@
7577
window.addEventListener("beforeinstallprompt", (event) => {
7678
event.preventDefault();
7779
installPrompt = event;
78-
showInstallHeader();
80+
if (localStorage.getItem(`hide-install-header-for-${slug}`) === 'true') {
81+
hideInstallHeader();
82+
} else {
83+
showInstallHeader();
84+
}
7985
});
8086
installButton.addEventListener("click", async () => {
8187
if (!installPrompt) {
@@ -86,6 +92,7 @@
8692
hideInstallHeader();
8793
});
8894
closeInstallButton.addEventListener("click", () => {
95+
localStorage.setItem(`hide-install-header-for-${slug}`, 'true');
8996
hideInstallHeader();
9097
});
9198
function hideInstallHeader() {
@@ -97,7 +104,6 @@
97104

98105
// Boot Playground
99106
import { startPlaygroundWeb } from "https://playground.wordpress.net/client/index.js";
100-
const slug = "{{PWA_SLUG}}";
101107

102108
function isWordPressInstalled(slug) {
103109
return localStorage.getItem(`wordpress-installed-for-${slug}`) === 'true';

0 commit comments

Comments
 (0)