Skip to content

Commit

Permalink
feat: check for matches
Browse files Browse the repository at this point in the history
  • Loading branch information
bwlng committed Aug 21, 2023
1 parent 534491f commit 4744b1e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 17 deletions.
7 changes: 1 addition & 6 deletions assets/js/form.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
const form = document.querySelector('[data-form]');

if (!form) {
return;
}

const onSuccess = (response) => {
console.log({ response })
const node = document.createElement('div');
node.classList.add('text-green-500');
node.innerHTML = `Thank you for your message.`;
Expand Down Expand Up @@ -39,4 +34,4 @@ const handleSubmit = event => {
})
}

form.addEventListener("submit", handleSubmit)
form?.addEventListener("submit", handleSubmit)
16 changes: 6 additions & 10 deletions assets/js/masthead-menu.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
const mastheadMenu = document.querySelector("[data-masthead-menu]");

if (!mastheadMenu) {
return;
}

const mastheadMenuToggle = mastheadMenu.querySelector("[data-masthead-menu-toggle]");
const mastheadMenuToggle = mastheadMenu?.querySelector("[data-masthead-menu-toggle]");

const onMastheadMenuToggleClick = (event) => {
event.preventDefault();
Expand All @@ -15,9 +11,9 @@ const onMastheadMenuToggleClick = (event) => {
target.setAttribute("aria-expanded", !expanded);
}

mastheadMenuToggle.addEventListener("click", onMastheadMenuToggleClick);
mastheadMenuToggle?.addEventListener("click", onMastheadMenuToggleClick);

const mastheadMenuClose = mastheadMenu.querySelector("[data-masthead-menu-close]");
const mastheadMenuClose = mastheadMenu?.querySelector("[data-masthead-menu-close]");

const onMastheadMenuCloseClick = (event) => {
event.preventDefault();
Expand All @@ -27,19 +23,19 @@ const onMastheadMenuCloseClick = (event) => {
target.setAttribute("aria-expanded", false);
}

mastheadMenuClose.addEventListener("click", onMastheadMenuCloseClick);
mastheadMenuClose?.addEventListener("click", onMastheadMenuCloseClick);

let prevWindowWidth = window.innerWidth;

function setAriaExpanded() {
// If the previous window width was greater than or equal to 768, set aria-expanded to false so that the menu is collapsed
if (window.innerWidth < 768) {
if (prevWindowWidth >= 768) {
mastheadMenuToggle.setAttribute('aria-expanded', 'false');
mastheadMenuToggle?.setAttribute('aria-expanded', 'false');
}
} else {
// Otherwise, set aria-expanded to true so that the menu is expanded
mastheadMenuToggle.setAttribute('aria-expanded', 'true');
mastheadMenuToggle?.setAttribute('aria-expanded', 'true');
}
// Update the previous window width so the next time this function is called, we can compare the previous width to the current width
prevWindowWidth = window.innerWidth;
Expand Down
2 changes: 1 addition & 1 deletion assets/js/video.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const videos = document.querySelectorAll("[data-video]");

videos.forEach((video) => {
videos?.forEach((video) => {
const observer = new IntersectionObserver(entries => {
entries.forEach(entry => {
if (entry.isIntersecting) {
Expand Down

0 comments on commit 4744b1e

Please sign in to comment.