Skip to content

Commit

Permalink
Merge branch 'main' into minor-change
Browse files Browse the repository at this point in the history
  • Loading branch information
jindaliiita authored Jun 8, 2024
2 parents e5e8e88 + 9153bac commit d685ca4
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 0 deletions.
88 changes: 88 additions & 0 deletions blocks/floatingagent/floatingagent.css
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;
}
}
59 changes: 59 additions & 0 deletions blocks/floatingagent/floatingagent.js
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);
}

0 comments on commit d685ca4

Please sign in to comment.