Skip to content

Commit

Permalink
Agent Address block added (#245)
Browse files Browse the repository at this point in the history
* Agent Address block added

* Review Comments incorporated

---------

Co-authored-by: piyushjindal <[email protected]>
  • Loading branch information
jindaliiita and piyushjindal authored Jun 10, 2024
1 parent 9153bac commit b5466ba
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
35 changes: 35 additions & 0 deletions blocks/agent-address/agent-address.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.agent-address.block {
padding: 2rem;
background-color: var(--tertiary-color);
}

.agent-address.block .address {
margin-bottom: 2rem;
}

.agent-address.block .address>p {
margin-bottom: 0;
font-size: var(--body-font-size-xs);
}

.agent-address.block a {
border: 1px solid var(--primary-color);
color: var(--primary-color);
font-weight: var(--font-weight-bold);
letter-spacing: var(--letter-spacing-m);
text-transform: uppercase;
padding: 0.5rem 1rem;
text-decoration: none;
font-size: var(--body-font-size-s);
}

.agent-address.block a:hover {
color: var(--primary-light);
background-color: var(--primary-color);
}

@media (min-width: 600px) {
.agent-address.block {
display: none;
}
}
22 changes: 22 additions & 0 deletions blocks/agent-address/agent-address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { getMetadata } from '../../scripts/aem.js';
import {
a, div, p,
} from '../../scripts/dom-helpers.js';

export default function decorate(block) {
const streetAddress = getMetadata('streetaddress');
const addressLocality = getMetadata('addresslocality');
const addressRegion = getMetadata('addressregion');
const postalCode = getMetadata('postalcode');

const textDiv = div({ class: 'address' },
p('Berkshire Hathaway HomeServices'),
p('Commonwealth Real Estate'),
p(streetAddress),
p(`${addressLocality}, ${addressRegion} ${postalCode}`),
);
const text = `${streetAddress}, ${addressLocality}, ${addressRegion} ${postalCode}`;

const anchor = a({ href: `https://maps.google.com/maps?q=${text}`, target: '_blank' }, 'Directions');
block.replaceChildren(textDiv, anchor);
}

0 comments on commit b5466ba

Please sign in to comment.