-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnewsletter.html
77 lines (71 loc) · 2.15 KB
/
newsletter.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Static Newsletter</title>
<style>
@import url(./tailwind.min.css);
html,
body {
font-family: "Montserrat", sans-serif;
}
</style>
<script>
window.onload = () => {
const baseUrl = window.location.href
.split("/")
.slice(0, -1)
.join("/")
.replace("static", "await");
document.getElementById("submit").addEventListener("click", (e) => {
e.preventDefault();
const message = document.getElementById("message");
message.classList.remove("hidden");
const email = document.getElementById("email").value;
if (email) {
fetch(`${baseUrl}/subscribe`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email,
status: "subscribed",
}),
})
.then((res) => res.json())
.then(({ status, email_address }) => {
message.innerHTML = `Email ${email_address} is ${status}!`;
});
}
});
};
</script>
</head>
<body>
<div class="w-full p-6">
<div class="bg-white p-6 w-50 border-solid border-2 border-gray-900">
<h1 class="text-xl pb-2 font-bold">Your Newsletter</h1>
<p class="pb-2 text-lg text-gray-700 hidden" id="message">
Subscribing...
</p>
<form class="flex">
<input
placeholder="Enter email"
id="email"
type="email"
class="appearance-none border-2 border-gray-900 w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none"
/>
<button
type="submit"
id="submit"
class="bg-gray-900 text-white text-center items-center flex justify-center px-4"
>
Subscribe
</button>
</form>
</div>
</div>
</body>
</html>