From f4502bdc44424a05abdd26d19690a7d19eed443b Mon Sep 17 00:00:00 2001 From: piyushjindal Date: Fri, 7 Jun 2024 14:57:27 +0530 Subject: [PATCH 1/2] Agent Address block added --- blocks/agent-address/agent-address.css | 35 ++++++++++++++++++++++++++ blocks/agent-address/agent-address.js | 22 ++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 blocks/agent-address/agent-address.css create mode 100644 blocks/agent-address/agent-address.js diff --git a/blocks/agent-address/agent-address.css b/blocks/agent-address/agent-address.css new file mode 100644 index 00000000..bc074896 --- /dev/null +++ b/blocks/agent-address/agent-address.css @@ -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; + } +} diff --git a/blocks/agent-address/agent-address.js b/blocks/agent-address/agent-address.js new file mode 100644 index 00000000..0395ec94 --- /dev/null +++ b/blocks/agent-address/agent-address.js @@ -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); +} From e7bb6b50d55e22b257dea84daf166ffbcc88e2e8 Mon Sep 17 00:00:00 2001 From: piyushjindal Date: Sat, 8 Jun 2024 12:41:35 +0530 Subject: [PATCH 2/2] Review Comments incorporated --- blocks/agent-address/agent-address.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/blocks/agent-address/agent-address.js b/blocks/agent-address/agent-address.js index 0395ec94..187419f0 100644 --- a/blocks/agent-address/agent-address.js +++ b/blocks/agent-address/agent-address.js @@ -10,10 +10,10 @@ export default function decorate(block) { const postalCode = getMetadata('postalcode'); const textDiv = div({ class: 'address' }, - p({}, 'Berkshire Hathaway HomeServices'), - p({}, 'Commonwealth Real Estate'), - p({}, streetAddress), - p({}, `${addressLocality}, ${addressRegion} ${postalCode}`), + p('Berkshire Hathaway HomeServices'), + p('Commonwealth Real Estate'), + p(streetAddress), + p(`${addressLocality}, ${addressRegion} ${postalCode}`), ); const text = `${streetAddress}, ${addressLocality}, ${addressRegion} ${postalCode}`;