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 branch 'main' into minor-change
- Loading branch information
Showing
2 changed files
with
147 additions
and
0 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,88 @@ | ||
.floatingagent.block { | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100px; | ||
background-color: var(--white); | ||
padding: 10px; | ||
border-top: 1px solid #ccc; | ||
z-index: 999; | ||
} | ||
|
||
.floatingagent.block > .floating-agent-col { | ||
display: none; | ||
} | ||
|
||
.floatingagent.block > .agentinfo { | ||
display: none; | ||
} | ||
|
||
.floatingagent.block > .contactagent { | ||
display: block; | ||
align-self: center; | ||
background: var(--primary-color); | ||
color: var(--tertiary-color); | ||
border: 0; | ||
padding: 10px; | ||
margin-left: 35%; | ||
} | ||
|
||
@media (min-width: 600px) { | ||
.floatingagent.block { | ||
justify-content: space-between; | ||
} | ||
|
||
.floatingagent.block > .floating-agent-col { | ||
margin-left: 100px; | ||
display: flex; | ||
margin-right: 10px; | ||
flex: none; | ||
margin-bottom: 20px; | ||
} | ||
|
||
.floatingagent.block > .agentinfo { | ||
display: block; | ||
flex-grow: 1; | ||
margin-top: 10px; | ||
margin-bottom: 15px; | ||
} | ||
|
||
.floatingagent.block > .agentinfo > p { | ||
margin-block-end: 0; | ||
font-family: var(--font-family-primary); | ||
font-size: var(--body-font-size-xxs); | ||
font-style: normal; | ||
font-weight: var(--font-weight-normal); | ||
letter-spacing: normal; | ||
color: #2a2223; | ||
} | ||
|
||
.floatingagent.block > .agentinfo > h2 { | ||
font-size: var(--heading-font-size-m); | ||
line-height: 130%; | ||
letter-spacing: var(--letter-spacing-xxxs); | ||
vertical-align: top; | ||
color: #2a2223; | ||
width: max-content; | ||
} | ||
|
||
.floatingagent.block > .floating-agent-col > picture { | ||
height: 40px; | ||
width: 30px; | ||
margin-right: 40px; | ||
} | ||
|
||
.floatingagent.block > .floating-agent-col > picture > img { | ||
display: inline; | ||
} | ||
|
||
.floatingagent.block > .contactagent { | ||
flex: none; | ||
margin-right: 5%; | ||
margin-left: 10px; | ||
} | ||
} |
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,59 @@ | ||
import { | ||
getMetadata, | ||
} from '../../scripts/aem.js'; | ||
import { | ||
button, | ||
div, | ||
h2, | ||
img, | ||
p, | ||
strong, | ||
} from '../../scripts/dom-helpers.js'; | ||
|
||
export default function decorate(block) { | ||
const agentName = getMetadata('name'); | ||
const agentDesc = getMetadata('desc'); | ||
const pic = getMetadata('pic'); | ||
const lic = getMetadata('lic'); | ||
|
||
const agentPicture = document.createElement('picture'); | ||
agentPicture.appendChild(img({ | ||
loading: 'lazy', | ||
alt: 'Agent Image', | ||
src: pic, | ||
width: '48', | ||
height: '64', | ||
style: 'width: 48px; height: 64px;', | ||
})); | ||
|
||
const agentInfo = div({ class: 'agentinfo' }, | ||
h2(strong(agentName)), | ||
p(agentDesc), | ||
p(lic), | ||
); | ||
|
||
const contactButton = button({ class: 'contactagent' }, 'CONTACT AGENT'); | ||
|
||
block.append( | ||
div({ class: 'floating-agent-col' }, agentPicture), | ||
agentInfo, | ||
contactButton, | ||
); | ||
const displayedElement = document.querySelector('.floatingagent'); | ||
|
||
const heroElement = document.querySelector('.hero-wrapper'); | ||
|
||
const observer = new IntersectionObserver((entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.isIntersecting) { | ||
displayedElement.style.display = 'none'; | ||
} else { | ||
displayedElement.style.display = 'flex'; | ||
} | ||
}); | ||
}, { | ||
threshold: [0], | ||
}); | ||
|
||
observer.observe(heroElement); | ||
} |