Skip to content

Commit

Permalink
Add hovering subscribe shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
yanirs committed Jan 17, 2024
1 parent 4f63eb8 commit 1c332eb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
23 changes: 23 additions & 0 deletions assets/css/extended/footer.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,26 @@ form.mailing-list input[type="submit"] {
padding-bottom: 10px;
padding-top: 0;
}

.mailing-list-link {
background: var(--tertiary);
color: var(--primary);
font-size: 14px;
border-radius: 2px;
padding: 6px;
visibility: hidden;
position: fixed;
top: 2px;
right: 2px;
z-index: 99;
transition: visibility 0.5s, opacity 0.8s linear;
}

.mailing-list-link:hover {
background: var(--primary);
color: var(--theme);
}

.mailing-list-link:focus {
outline: 0;
}
18 changes: 17 additions & 1 deletion layouts/partials/extend_footer.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<a href="#mailing-list-email" aria-label="subscribe to mailing list" class="mailing-list-link" id="mailing-list-link">
⬇ Subscribe below
</a>

<div class="mailing-list-container">
<form
class="mailing-list"
Expand Down Expand Up @@ -29,15 +33,27 @@
</div>

<script>
// Set up the collapsible menu.
const menuTrigger = document.querySelector("#menu-trigger");
const menuElem = document.querySelector(".menu");
menuTrigger.addEventListener("click", function () {
menuElem.classList.toggle("hidden");
});
// hide menu when clicked outside
document.body.addEventListener('click', function (event) {
if (!menuTrigger.contains(event.target)) {
menuElem.classList.add("hidden");
}
});

// Show / hide mailing list link when scrolling (adapted from top-link functionality).
const mailingListButton = document.getElementById("mailing-list-link");
window.onscroll = function () {
if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
mailingListButton.style.visibility = "visible";
mailingListButton.style.opacity = "1";
} else {
mailingListButton.style.visibility = "hidden";
mailingListButton.style.opacity = "0";
}
};
</script>

0 comments on commit 1c332eb

Please sign in to comment.