generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #184 from hlxsites/bug/sidebar-customerquote-issue
Bug/sidebar customerquote issue
- Loading branch information
Showing
3 changed files
with
31 additions
and
68 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
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,43 +1,14 @@ | ||
export default function decorate(block) { | ||
const clonedBlock = block.cloneNode(true); | ||
const pictureElement = clonedBlock.querySelector('picture'); | ||
const moduleDiv = document.createElement('div'); | ||
moduleDiv.classList.add('hs_cos_wrapper', 'hs_cos_wrapper_widget', 'hs_cos_wrapper_type_module', 'module-1'); | ||
moduleDiv.setAttribute('data-hs-cos-type', 'module'); | ||
moduleDiv.setAttribute('data-hs-cos-general-type', 'widget'); | ||
const quoteboxDiv = document.createElement('div'); | ||
quoteboxDiv.classList.add('quote-box'); | ||
const blockquoteDiv = document.createElement('blockquote'); | ||
blockquoteDiv.classList.add('quote'); | ||
blockquoteDiv.textContent = clonedBlock.querySelector('blockquote > p').textContent; | ||
quoteboxDiv.append(blockquoteDiv); | ||
const para = document.createElement('p'); | ||
para.classList.add('details'); | ||
const spanInside = document.createElement('span'); | ||
spanInside.classList.add('name'); | ||
spanInside.textContent = clonedBlock.querySelector('blockquote + p').textContent; | ||
para.append(spanInside); | ||
const spanTitle = document.createElement('span'); | ||
spanTitle.classList.add('title'); | ||
spanTitle.textContent = clonedBlock.querySelector('blockquote + p + p').textContent; | ||
para.append(spanTitle); | ||
quoteboxDiv.append(para); | ||
const spanIconWrapper = document.createElement('span'); | ||
spanIconWrapper.classList.add('accentColor1', 'fa'); | ||
const spanIcon = document.createElement('i'); | ||
spanIcon.classList.add('fa', 'fa-quote-right'); | ||
spanIconWrapper.append(spanIcon); | ||
quoteboxDiv.append(spanIconWrapper); | ||
const imageWrapper = document.createElement('div'); | ||
imageWrapper.classList.add('testimonial-headshot', 'text-center'); | ||
const image = document.createElement('img'); | ||
image.setAttribute('width', `${pictureElement.querySelector('img').width}`); | ||
image.setAttribute('height', `${pictureElement.querySelector('img').height}`); | ||
image.setAttribute('alt', `${pictureElement.querySelector('img').alt}`); | ||
image.setAttribute('src', `${pictureElement.querySelector('img').src}`); | ||
imageWrapper.append(image); | ||
moduleDiv.append(quoteboxDiv); | ||
moduleDiv.append(imageWrapper); | ||
const quoteWrapper = document.createElement('div'); | ||
quoteWrapper.classList.add('quote-wrapper'); | ||
[...block.children].forEach((element) => { quoteWrapper.append(element); }); | ||
quoteWrapper.children[1].classList.add('details'); | ||
quoteWrapper.children[2].classList.add('title'); | ||
block.textContent = ''; | ||
block.append(moduleDiv); | ||
block.append(quoteWrapper); | ||
if (quoteWrapper.children[3] && quoteWrapper.children[3].querySelector('picture')) { | ||
quoteWrapper.children[3].classList.add('testimonial-headshot'); | ||
quoteWrapper.classList.add('bottom-icon'); | ||
block.appendChild(quoteWrapper.children[3]); | ||
} | ||
} |
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