-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
106 lines (101 loc) · 3.46 KB
/
index.html
File metadata and controls
106 lines (101 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Prism | Gradient Viewer</title>
<link rel="manifest" href="manifest.json">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="card">
<h2 id="title">Prism</h2>
<p id="guide">Enter a CSS gradient or make your own...</p>
<input type="text" id="gradientInput" />
<div class="gradients">
<button
class="gradientBtn"
style="background: linear-gradient(to right, #ff6a00, #ee0979);"
data-gradient="linear-gradient(to right, #ff6a00, #ee0979)"
>
Sunset
</button>
<button
class="gradientBtn"
style="background: linear-gradient(to right, #00f260, #0575e6);"
data-gradient="linear-gradient(to right, #00f260, #0575e6)"
>
Ocean
</button>
<button
class="gradientBtn"
style="background: linear-gradient(to right, #f7971e, #ffd200);"
data-gradient="linear-gradient(to right, #f7971e, #ffd200)"
>
Gold
</button>
<button
class="gradientBtn"
style="background: linear-gradient(to right, #00c6ff, #0072ff);"
data-gradient="linear-gradient(to right, #00c6ff, #0072ff)"
>
Sky
</button>
<button
class="gradientBtn"
style="background: linear-gradient(to right, #8e2de2, #4a00e0);"
data-gradient="linear-gradient(to right, #8e2de2, #4a00e0)"
>
Purple
</button>
</div>
<div class="colorPickers" id="colorPickers"></div>
<div class="stopControls">
<button id="addStop">+ Add Stop</button>
<button id="removeStop">− Remove Stop</button>
</div>
<button class="gradientBtn" style="background: #00c6ff" id="install-button" hidden>Install App</button>
</div>
<script src="main.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function () {
// Register the service worker
if ("serviceWorker" in navigator) {
navigator.serviceWorker.register("service-worker.js");
}
let deferredPrompt;
const installButton = document.getElementById("install-button");
// Listen for the install prompt
window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault();
deferredPrompt = e;
installButton.hidden = false;
});
// Handle install button click
installButton.addEventListener("click", async () => {
const isStandalone =
window.matchMedia("(display-mode: standalone)").matches ||
window.navigator.standalone;
if (isStandalone) {
console.log("App is already installed");
return;
}
if (deferredPrompt) {
deferredPrompt.prompt();
const { outcome } = await deferredPrompt.userChoice;
deferredPrompt = null;
console.log(
outcome === "accepted"
? "User accepted install prompt"
: "User dismissed install prompt"
);
} else {
if (window.matchMedia("(display-mode: browser)").matches) {
window.location.assign("chrome://apps/");
}
}
});
});
</script>
</body>
</html>