-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Floating agent bottom #238
Changes from 9 commits
2162427
d50dfb4
a271faa
0288ab3
a35e454
5c9c2ba
402d645
39647a2
af9c03a
8e64dff
8fcc666
94ba880
dba5aa8
c599e54
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
.floatingagent.block { | ||
display: none; | ||
align-items: center; | ||
justify-content: space-between; | ||
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 { | ||
margin-left: 100px; | ||
display: flex; | ||
margin-right: 10px; | ||
flex: none; | ||
} | ||
|
||
.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: .18px; | ||
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 > .agentinfo { | ||
flex-grow: 1; | ||
margin-top: 10px; | ||
} | ||
|
||
.floatingagent.block > .contactagent { | ||
align-self: center; | ||
background: var(--primary-color); | ||
color: var(--tertiary-color); | ||
border: 0; | ||
flex: none; | ||
padding: 10px; | ||
margin-right: 5%; | ||
} | ||
|
||
@media (max-width: 600px) { | ||
.floatingagent.block { | ||
justify-content: flex-start; | ||
} | ||
|
||
.floatingagent.block > .floating-agent-col > picture > img, | ||
.floatingagent.block > .agentinfo { | ||
display: none; | ||
} | ||
|
||
.floatingagent.block > .contactagent { | ||
display: block; | ||
margin-left: 10px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
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: '', | ||
width: '48', | ||
height: '64', | ||
style: 'width: 48px; height: 64px;', | ||
})); | ||
|
||
const agentInfo = div({ class: 'agentinfo' }, | ||
bstopp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
h2(strong('')), | ||
p(''), | ||
p(''), | ||
); | ||
|
||
const contactButton = button({ class: 'contactagent' }, 'CONTACT AGENT'); | ||
|
||
block.append( | ||
div({ class: 'floating-agent-col' }, agentPicture), | ||
agentInfo, | ||
contactButton, | ||
); | ||
|
||
const agentImageElement = agentPicture.querySelector('img'); | ||
const agentInfoElements = agentInfo.children; | ||
|
||
agentImageElement.src = pic; | ||
agentInfoElements[0].innerHTML = `<strong>${agentName}</strong>`; | ||
agentInfoElements[1].textContent = agentDesc; | ||
agentInfoElements[2].textContent = lic; | ||
} | ||
RitwikSrivastava marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this move to inside the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definitely thats right. and that will ensure that the observer is only created where the decorate function is executed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you flip this? always start with mobile view as the default, then it's
min-width
on up. I realize that will probably have pretty significant changes to the styling.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected.