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.
- Loading branch information
Showing
39 changed files
with
2,806 additions
and
170 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
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
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
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,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; | ||
} | ||
} |
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,22 @@ | ||
import { getMetadata } from '../../scripts/aem.js'; | ||
import { | ||
a, div, p, | ||
} from '../../scripts/dom-helpers.js'; | ||
|
||
export default function decorate(block) { | ||
const streetAddress = getMetadata('street-address'); | ||
const city = getMetadata('city'); | ||
const state = getMetadata('state'); | ||
const zip = getMetadata('zip'); | ||
|
||
const textDiv = div({ class: 'address' }, | ||
p('Berkshire Hathaway HomeServices'), | ||
p('Commonwealth Real Estate'), | ||
p(streetAddress), | ||
p(`${city}, ${state} ${zip}`), | ||
); | ||
const text = `${streetAddress}, ${city}, ${state} ${zip}`; | ||
|
||
const anchor = a({ href: `https://maps.google.com/maps?q=${text}`, target: '_blank' }, 'Directions'); | ||
block.replaceChildren(textDiv, anchor); | ||
} |
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
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,100 @@ | ||
@import url('../shared/property/cards.css'); | ||
|
||
.agent-property.block { | ||
overflow: hidden; | ||
width: 100%; | ||
} | ||
|
||
.agent-property.block a { | ||
text-decoration: none; | ||
} | ||
|
||
.agent-property.block .gmap-canvas { | ||
width: 100%; | ||
height: 0; | ||
transition: height 0.5s ease; | ||
display: none; | ||
} | ||
|
||
.agent-property.block .view-toggle { | ||
margin-bottom: 20px; | ||
} | ||
|
||
.agent-property.block .gmap-canvas.active { | ||
display:block; | ||
height: 500px; | ||
} | ||
|
||
.agent-property.block .view-toggle .card-view { | ||
display: none; | ||
margin-left: 70%; | ||
font-family: Manrope, sans-serif; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 700; | ||
letter-spacing: 1.6px; | ||
text-transform: uppercase; | ||
border: 1px solid #2a2223; | ||
line-height: 35px; | ||
background: #fff; | ||
} | ||
|
||
.agent-property.block .view-toggle .map-view { | ||
margin-left: 70%; | ||
font-family: Manrope, sans-serif; | ||
font-size: 16px; | ||
font-style: normal; | ||
font-weight: 700; | ||
letter-spacing: 1.6px; | ||
text-transform: uppercase; | ||
border: 1px solid #2a2223; | ||
line-height: 35px; | ||
background: #fff; | ||
} | ||
|
||
.agent-property.block .header { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.agent-property.block .header > div { | ||
margin-bottom: 24px; | ||
} | ||
|
||
.agent-property.block .header > div > span { | ||
color: var(--primary-color); | ||
font-size: var(--heading-font-size-l); | ||
font-weight: var(--font-weight-semibold); | ||
letter-spacing: initial; | ||
line-height: var(--line-height-m); | ||
text-transform: capitalize; | ||
} | ||
|
||
.agent-property.block .header > div > p { | ||
margin: 0; | ||
} | ||
|
||
.agent-property.block .property-list-cards .listing-tile .extra-info { | ||
display:none; | ||
} | ||
|
||
.liveby-community .agent-property.block { | ||
max-width: 1150px; | ||
margin: auto; | ||
} | ||
|
||
@media (min-width: 600px) { | ||
.agent-property.block .header { | ||
flex-direction: row; | ||
justify-content: space-between; | ||
} | ||
|
||
.agent-property.block .header .button-container { | ||
justify-content: flex-end; | ||
} | ||
|
||
.agent-property.block .view-toggle .map-view , .agent-property.block .view-toggle .card-view { | ||
margin-left: 90.5%; | ||
width: 115px; | ||
} | ||
} |
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,81 @@ | ||
/* global google */ | ||
|
||
import { render as renderCards } from '../shared/property/cards.js'; | ||
import { button, div } from '../../scripts/dom-helpers.js'; | ||
import loadMaps from '../../scripts/google-maps/index.js'; | ||
import { loadScript, getMetadata } from '../../scripts/aem.js'; | ||
|
||
const cardView = button({ class: 'card-view' }, 'Grid View'); | ||
const mapView = button({ class: 'map-view' }, 'Map View'); | ||
const viewToggle = div({ class: 'view-toggle' }); | ||
const map = div({ class: 'gmap-canvas' }); | ||
const agentId = getMetadata('agent-id'); | ||
let centerlat; | ||
let centerlong; | ||
let data; | ||
|
||
function initMap(block, properties) { | ||
const ele = block.querySelector('.gmap-canvas'); | ||
const gmap = new google.maps.Map(ele, { | ||
zoom: 9, // Set an appropriate zoom level | ||
center: { lat: centerlat, lng: centerlong }, // Set a default center | ||
mapTypeId: google.maps.MapTypeId?.ROADMAP, | ||
clickableIcons: false, | ||
gestureHandling: 'cooperative', | ||
visualRefresh: true, | ||
disableDefaultUI: true, | ||
}); | ||
|
||
const createMarker = (property, amap) => new google.maps.Marker({ | ||
position: { lat: parseFloat(property.Latitude), lng: parseFloat(property.Longitude) }, | ||
map: amap, | ||
title: property.StreetName, | ||
}); | ||
|
||
properties.forEach((property) => { | ||
createMarker(property, gmap); | ||
}); | ||
} | ||
|
||
export default async function decorate(block) { | ||
const list = document.createElement('div'); | ||
list.classList.add('property-list-cards', 'rows-1'); | ||
viewToggle.append(cardView, mapView); | ||
block.append(viewToggle, list, map); | ||
|
||
try { | ||
const response = await fetch(`/bin/bhhs/agentPropertyListingsServlet.${agentId}.json`); | ||
data = await response.json(); | ||
if (data) { | ||
const [firstProperty] = data.listings.properties; | ||
const { Latitude: latitude, Longitude: longitude } = firstProperty; | ||
centerlat = parseFloat(latitude); | ||
centerlong = parseFloat(longitude); | ||
renderCards(list, data.listings.properties); | ||
} | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error('Error fetching agent properties', error); | ||
} | ||
|
||
document.querySelector('.card-view').addEventListener('click', () => { | ||
document.querySelector('.property-list-cards').style.display = 'grid'; | ||
document.querySelector('.card-view').style.display = 'none'; | ||
document.querySelector('.map-view').style.display = 'block'; | ||
document.querySelector('.gmap-canvas').classList.remove('active'); | ||
}); | ||
|
||
document.querySelector('.map-view').addEventListener('click', async () => { | ||
document.querySelector('.gmap-canvas').classList.add('active'); | ||
document.querySelector('.map-view').style.display = 'none'; | ||
document.querySelector('.card-view').style.display = 'block'; | ||
document.querySelector('.property-list-cards').style.display = 'none'; | ||
loadMaps(); | ||
await google.maps.importLibrary('core'); | ||
await google.maps.importLibrary('maps'); | ||
await google.maps.importLibrary('marker'); | ||
await loadScript('https://unpkg.com/@googlemaps/markerclusterer/dist/index.min.js', { type: 'application/javascript' }); | ||
await loadScript('https://unpkg.com/jsts/dist/jsts.min.js', { type: 'application/javascript' }); | ||
initMap(block, data.listings.properties); | ||
}); | ||
} |
Oops, something went wrong.