Skip to content

Commit

Permalink
chore: hide subscribe button if the server is down (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
meysam81 authored Jan 11, 2025
1 parent bffe4a3 commit 66ff801
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/static/subscribe.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
flex-direction: column;
}

#subscribe-container-82087868.hidden {
display: none;
}

#subscribe-form-9b27c56e.hidden {
display: none;
}
Expand Down
14 changes: 13 additions & 1 deletion docs/static/subscribe.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
document$.subscribe(function prepareSubForm() {
document$.subscribe(async function prepareSubForm() {
var formParentDiv = document.getElementById("subscribe-form-9b27c56e");
var subscriptionForm = document.getElementById("subscription-form-b8eb1947");
var subscribeButton = document.getElementById("subscribe-button-ea4577c9");
Expand Down Expand Up @@ -81,6 +81,18 @@ document$.subscribe(function prepareSubForm() {
submitInfo.classList.remove("hidden");
}

async function renderSubscriptionForm() {
console.log("Fetching newsletter subscription form...");

var response = await fetch("https://newsletter.developer-friendly.blog");
if (response.status == 200) {
document
.getElementById("subscribe-container-82087868")
.classList.remove("hidden");
}
}

subscribeButton.addEventListener("click", subscribeButtonClick);
subscriptionForm.addEventListener("submit", subscribeButtonSubmit);
await renderSubscriptionForm();
});
2 changes: 1 addition & 1 deletion overrides/partials/subscription-form.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="subscribe-container-82087868">
<div id="subscribe-container-82087868" class="hidden">
<button id="subscribe-button-ea4577c9">
<i class="icon-paper-plane-abdcf51b"></i>
</button>
Expand Down

0 comments on commit 66ff801

Please sign in to comment.