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 #59 from hlxsites/feature/template-hero-bugs
Feature/template hero bugs
- Loading branch information
Showing
6 changed files
with
66 additions
and
86 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 |
---|---|---|
@@ -1,50 +1,37 @@ | ||
/* block specific CSS goes here */ | ||
|
||
main .hero-container > div { | ||
max-width: unset; | ||
.hero .hero-content { | ||
min-height: 310px; | ||
display: flex; | ||
align-items: center; | ||
color: #fff; | ||
} | ||
|
||
main .hero-container { | ||
padding: 0; | ||
.hero .bg-primary { | ||
background-position: 50% 50%; | ||
background-size: cover; | ||
} | ||
|
||
#heading { | ||
display: block; | ||
} | ||
|
||
/* main .hero { | ||
position: relative; | ||
padding: 32px; | ||
min-height: 300px; | ||
} */ | ||
|
||
main .hero h1 { | ||
.hero .hero-content h2 { | ||
line-height: 1.2; | ||
padding: 0; | ||
color: white; | ||
font-size: 44px; | ||
text-shadow: 0 0 6px rgba(0,0,0,50%); | ||
} | ||
|
||
/* main .hero picture { | ||
position: absolute; | ||
height : 310px; | ||
z-index: -1; | ||
top: 0; | ||
left: 0; | ||
bottom: 0; | ||
right: 0; | ||
object-fit: cover; | ||
box-sizing: border-box; | ||
} */ | ||
@media (max-width: 1120px) { | ||
.hero .hero-content { | ||
min-height: 260px; | ||
} | ||
} | ||
|
||
/* main .hero img { | ||
object-fit: cover; | ||
width: 100%; | ||
height: 100%; | ||
} */ | ||
@media (max-width: 860px) { | ||
.hero .hero-content { | ||
min-height: 220px; | ||
} | ||
} | ||
|
||
/* | ||
main .hero a:hover { | ||
color: white; | ||
} */ | ||
@media (max-width: 767px) { | ||
.hero .hero-content { | ||
min-height: 180px; | ||
} | ||
} |
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,25 +1,20 @@ | ||
export default function decorate() { | ||
const heroClass = document.getElementsByClassName('hero block'); | ||
heroClass[0].setAttribute('id', 'heading'); | ||
heroClass[0].children[0].setAttribute('class', 'outer'); | ||
heroClass[0].children[0].children[0].setAttribute('class', 'vertical'); | ||
const heroDiv = heroClass[0].children[0].children[0]; | ||
const pTags = heroDiv.getElementsByTagName('p'); | ||
const supTag = heroDiv.getElementsByTagName('sup'); | ||
supTag[0].style.fontSize = '60%'; | ||
const heroSrc = pTags[0].children[0].querySelector('img').src; | ||
heroClass[0].style.backgroundImage = `url('${heroSrc}')`; | ||
let innerElements = ''; | ||
for (let i = 0; i < pTags.length; i += 1) { | ||
if (pTags[i].outerHTML.includes('class')) { | ||
innerElements += pTags[i].innerHTML.replace('class="button"', 'style="background-color:#000;" class="hs-button" target="_blank"'); | ||
} else if (i === 1) { | ||
const heroTitle = pTags[i].outerHTML.replace(/<p[ ]*>/g, ''); | ||
innerElements += heroTitle.replace(/<\/p>/g, '<br>'); | ||
} else if (i === 2) { | ||
const heroDescription = pTags[i].outerHTML.replace(/<p[ ]*>/g, '<span style="font-size: 70%;">'); | ||
innerElements += heroDescription.replace(/<\/p>/g, '</span><br>'); | ||
export default function decorate(block) { | ||
const bgImage = block.children[0].querySelector('img'); | ||
|
||
const heroContainer = document.createElement('div'); | ||
heroContainer.className = 'bg-primary'; | ||
|
||
// Set background image using CSS property | ||
heroContainer.style.backgroundImage = `url(${bgImage.src})`; | ||
heroContainer.style.backgroundSize = 'cover'; // Adjust as needed | ||
|
||
if (block.children.length > 1) { | ||
const additionalContent = block.children[1]; // Change the index if needed | ||
if (additionalContent) { | ||
additionalContent.classList.add('outer', 'hero-content'); | ||
heroContainer.appendChild(additionalContent); | ||
} | ||
} | ||
heroDiv.innerHTML = `<h1>${innerElements}</h1>`; | ||
block.innerText = ''; | ||
block.appendChild(heroContainer); | ||
} |
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
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