From 28124d4ea132569a930c2a7eade318896d2a95ab Mon Sep 17 00:00:00 2001 From: Dave Nichols Date: Thu, 22 Aug 2024 17:47:28 +0100 Subject: [PATCH 1/2] Added option to hide the buttons --- blocks/event-summary/event-summary.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/blocks/event-summary/event-summary.js b/blocks/event-summary/event-summary.js index 38e01fa..ebcf2e3 100644 --- a/blocks/event-summary/event-summary.js +++ b/blocks/event-summary/event-summary.js @@ -22,6 +22,7 @@ export default async function decorate(block) { const image = getMetadata('og:image'); const registerButton = getMetadata('register-button'); + const meetingButton = getMetadata('meeting-button'); const title = getMetadata('og:title'); const description = getMetadata('og:description'); const type = getMetadata('type'); @@ -57,11 +58,16 @@ export default async function decorate(block) { registerButtonLink = a({ href: registerButton, title }, 'Register Today'); } const registerButtonContainer = p({ class: 'button-container find-out-more' }, strong(registerButtonLink)); - const talkButtonContainer = p({ class: 'button-container' }, strong(a({ href: '/about-us/contact-us', title }, 'Request a Meeting/Contact Us'))); + const talkButtonContainer = p({ class: 'button-container' }, strong(a({ href: meetingButton, title }, 'Request a Meeting/Contact Us'))); // Append elements to block block.appendChild(imageContainer); - block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer, talkButtonContainer))); + + if (meetingButton) { + block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer, talkButtonContainer))); + } else { + block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer))); + } // Add event listener to the 'Register Today' button registerButtonLink.addEventListener('click', (event) => { From b541c339e0b1fe5e1adccb233d9b8ce4ca6130bb Mon Sep 17 00:00:00 2001 From: Dave Nichols Date: Thu, 22 Aug 2024 18:48:51 +0100 Subject: [PATCH 2/2] Added check to the registerButton as well --- blocks/event-summary/event-summary.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/blocks/event-summary/event-summary.js b/blocks/event-summary/event-summary.js index ebcf2e3..6c533db 100644 --- a/blocks/event-summary/event-summary.js +++ b/blocks/event-summary/event-summary.js @@ -57,18 +57,26 @@ export default async function decorate(block) { } else { registerButtonLink = a({ href: registerButton, title }, 'Register Today'); } - const registerButtonContainer = p({ class: 'button-container find-out-more' }, strong(registerButtonLink)); - const talkButtonContainer = p({ class: 'button-container' }, strong(a({ href: meetingButton, title }, 'Request a Meeting/Contact Us'))); - // Append elements to block - block.appendChild(imageContainer); + let registerButtonContainer; + if (registerButton) { + registerButtonContainer = p({ class: 'button-container find-out-more' }, strong(a({ href: registerButton, title }, 'Register Today'))); + } else { + registerButtonContainer = ''; + } + let talkButtonContainer; if (meetingButton) { - block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer, talkButtonContainer))); + talkButtonContainer = p({ class: 'button-container' }, strong(a({ href: meetingButton, title }, 'Request a Meeting/Contact Us'))); } else { - block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer))); + talkButtonContainer = ''; } + // Append elements to block + block.appendChild(imageContainer); + + block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventSummary || description, registerButtonContainer, talkButtonContainer))); + // Add event listener to the 'Register Today' button registerButtonLink.addEventListener('click', (event) => { event.preventDefault();