generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f27dfc
commit 57f2b98
Showing
6 changed files
with
315 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
.breadcrumbs { | ||
grid-area: bread; | ||
display: inline-block; | ||
list-style: none; | ||
padding: 0; | ||
font-size: 14px; | ||
margin-bottom: 50px; | ||
} | ||
|
||
.breadcrumbs ul { | ||
padding-top: 0; | ||
margin-top: 0; | ||
} | ||
|
||
.breadcrumbs li { | ||
display: inline-block; | ||
padding: 10px 5px; | ||
text-transform: uppercase; | ||
} | ||
|
||
.breadcrumbs li a { | ||
color: #202020; | ||
text-decoration: none; | ||
} | ||
|
||
.breadcrumbs li:first-child { | ||
padding-left: 0; | ||
} | ||
|
||
.breadcrumbs li:last-child { | ||
font-weight: 600; | ||
} | ||
|
||
.breadcrumbs li::before { | ||
font-family: arial, sans-serif; | ||
font-style: normal; | ||
font-weight: 400; | ||
font-variant: normal; | ||
text-transform: none; | ||
line-height: 1; | ||
font-size: 14px; | ||
padding-right: 5px; | ||
} | ||
|
||
.breadcrumbs li:first-child::before { | ||
content: none; | ||
} | ||
|
||
.breadcrumbs li:not(:last-child)::after { | ||
content: ">\00a0"; | ||
padding: 0 2px 0 7px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { getMetadata } from '../../scripts/aem.js'; | ||
|
||
/** | ||
* | ||
* @param {HTMLElement} $block The main element | ||
*/ | ||
export default function decorate($block) { | ||
const title = getMetadata('og:title'); | ||
const $ul = document.createElement('ul'); | ||
$block.append($ul); | ||
const trail = [{ | ||
text: 'Home', | ||
link: '/', | ||
}, { | ||
text: 'Events', | ||
link: '/about-us/events-calendar', | ||
}, { | ||
text: title, | ||
}]; | ||
while (trail.length) { | ||
const step = trail.shift(); | ||
const $li = document.createElement('li'); | ||
$ul.append($li); | ||
let $wrap = $li; | ||
if (step.link) { | ||
$wrap = document.createElement('a'); | ||
$wrap.href = step.link; | ||
$li.append($wrap); | ||
} | ||
const $span = document.createElement('span'); | ||
$wrap.append($span); | ||
$span.textContent = step.text; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
.event-summary { | ||
display: flex; | ||
flex-wrap: wrap; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.event-details { | ||
flex: 1; | ||
max-width: calc(50% -20px); | ||
margin: 0 10px 10px 10px; | ||
} | ||
|
||
ul.keyword-list { | ||
margin: 0; | ||
padding: 0; | ||
list-style: none; | ||
} | ||
|
||
ul.keyword-list li:not(:last-of-type)::after { | ||
content: '|'; | ||
display: inline-block; | ||
margin-left: 10px; | ||
} | ||
|
||
ul.keyword-list li { | ||
display: inline-block; | ||
margin-right: 10px; | ||
position: relative; | ||
font-size: 18px; | ||
vertical-align: middle; | ||
} | ||
|
||
ul li { | ||
padding: 0 0 0 0 !important; | ||
} | ||
|
||
.event-date { | ||
font-size: 14px; | ||
padding-top: 0 !important; | ||
} | ||
|
||
.event-subtitle { | ||
font-size: 20px; | ||
font-weight: bold; | ||
margin-bottom: 12px; | ||
color: var(--primary-color); | ||
} | ||
|
||
.event-keywords { | ||
font-size: 18px; | ||
} | ||
|
||
.image-container { | ||
flex: 0 0 50%; | ||
max-width: 50%; | ||
margin-right: 30px; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.image-container .img { | ||
width: 100%; | ||
height: auto; | ||
object-fit: cover; | ||
} | ||
|
||
@media only screen and (max-width: 768px) { | ||
.image-container, | ||
.event-details { | ||
flex: 1 0 100%; | ||
max-width: 100%; | ||
} | ||
|
||
.event-details { | ||
margin-top: 20px; | ||
} | ||
} | ||
|
||
@media only screen and (min-width: 1024px) { | ||
.event-details { | ||
order: 1; | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import { getMetadata, createOptimizedPicture } from '../../scripts/aem.js'; | ||
import { | ||
div, h1, a, li, p, ul, | ||
strong, | ||
} from '../../scripts/dom-builder.js'; | ||
|
||
export default async function decorate(block) { | ||
const startDatestr = getMetadata('startdate'); | ||
const endDatestr = getMetadata('enddate'); | ||
const startDateParts = startDatestr.split('/'); | ||
const endDateParts = endDatestr.split('/'); | ||
const startDate = new Date(startDateParts[2], startDateParts[0], startDateParts[1]); | ||
const endDate = new Date(endDateParts[2], endDateParts[0], endDateParts[1]); | ||
const formattedStartDate = startDate.toLocaleDateString('en-Us', { month: 'short', day: '2-digit', year: 'numeric' }); | ||
const formattedEndDate = endDate.toLocaleDateString('en-Us', { month: 'short', day: '2-digit', year: 'numeric' }); | ||
const date = `${formattedStartDate.split(',')[0]} - ${formattedEndDate}`; | ||
const image = getMetadata('og:image'); | ||
const description = getMetadata('og:description'); | ||
const registerButton = getMetadata('register-button'); | ||
const title = getMetadata('og:title'); | ||
const type = getMetadata('type'); | ||
const region = getMetadata('region'); | ||
const address = getMetadata('address'); | ||
|
||
// Create elements | ||
const imageContainer = div( | ||
{ class: 'image-container' }, | ||
createOptimizedPicture(image, title), | ||
); | ||
|
||
const eventDate = p({ class: 'event-date' }, date); | ||
const eventSubtitle = h1({ class: 'event-subtitle' }, title); | ||
const keywordList = ul( | ||
{ class: 'keyword-list' }, | ||
li({ class: 'item type' }, type), | ||
li({ class: 'item region' }, region), | ||
li({ class: 'item address' }, address), | ||
); | ||
|
||
const eventDescription = p(description); | ||
const registerButtonLink = a({ href: registerButton, title }, 'Register Today'); | ||
const registerButtonContainer = p({ class: 'button-container find-out-more' }, strong(registerButtonLink)); | ||
|
||
// Append elements to block | ||
block.appendChild(imageContainer); | ||
block.appendChild(div({ class: 'event-details' }, eventDate, eventSubtitle, div({ class: 'event-keywords' }, keywordList), div({ class: 'event-description' }, eventDescription, registerButtonContainer))); | ||
|
||
// Add event listener to the 'Register Today' button | ||
registerButtonLink.addEventListener('click', (event) => { | ||
event.preventDefault(); | ||
|
||
const popupMessageBox = div({ class: 'popup-message' }); | ||
const message = document.createElement('p'); | ||
message.textContent = 'You are now moving to an external website.'; | ||
|
||
const proceedBtn = document.createElement('button'); | ||
proceedBtn.classList.add('proceed'); | ||
proceedBtn.textContent = 'Proceed'; | ||
|
||
const cancelBtn = document.createElement('button'); | ||
cancelBtn.classList.add('cancel'); | ||
cancelBtn.textContent = 'Cancel'; | ||
|
||
popupMessageBox.appendChild(message); | ||
popupMessageBox.appendChild(proceedBtn); | ||
popupMessageBox.appendChild(cancelBtn); | ||
block.appendChild(popupMessageBox); | ||
|
||
proceedBtn.addEventListener('click', () => { | ||
const ahref = registerButtonLink.getAttribute('href'); | ||
registerButtonLink.setAttribute('target', '_blank'); | ||
window.location.href = ahref; | ||
}); | ||
|
||
cancelBtn.addEventListener('click', () => { | ||
popupMessageBox.style.display = 'none'; | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
import { | ||
div, | ||
} from '../../scripts/dom-builder.js'; | ||
|
||
async function renderDetails(insertAfterElement) { | ||
const summary = div({ class: 'event-summary' }); | ||
insertAfterElement.parentNode.insertBefore(summary, insertAfterElement.nextSibling); | ||
const summaryWrapper = document.querySelector('event-summary-wrapper'); | ||
if (summaryWrapper) { | ||
const summary = document.querySelector('event-summary'); | ||
insertAfterElement.parentNode.insertBefore(summary, insertAfterElement.nextSibling); | ||
} | ||
} | ||
|
||
export default async function buildAutoBlocks() { | ||
const title = document.getElementById('event-details'); | ||
if (title) title.classList.add('event-title'); | ||
|
||
const moreBtn = document.querySelector('main strong > a:last-of-type'); | ||
if (moreBtn) { | ||
moreBtn.setAttribute('target', '_blank'); | ||
const par = moreBtn.closest('p'); | ||
par.classList.add('find-out-more'); | ||
} | ||
|
||
renderDetails(title); | ||
} |