Skip to content

Commit

Permalink
Merge branch 'main' into localNavSubItems
Browse files Browse the repository at this point in the history
  • Loading branch information
jsavella authored Dec 16, 2024
2 parents 5007547 + 91c9f98 commit 4f37af9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Your Project's Title...
Your project's description...
# Adobe Edge for Esri Digital Experience

This project leverages Adobe Edge to build and deploy websites. By utilizing Adobe Edge's capabilities, we aim to create engaging and dynamic content that effectively showcases Esri's products and services.

## Environments
- Preview: https://main--esri-eds--esri.aem.page/
Expand Down
6 changes: 6 additions & 0 deletions eds/blocks/local-navigation/local-navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,10 @@
.local-navigation calcite-icon {
display: none;
}

.local-navigation calcite-button {
inline-size: auto;
padding-inline: 0;
padding-block: var(--space-3);
}
}
34 changes: 31 additions & 3 deletions eds/blocks/local-navigation/local-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,28 @@ function appendPageTitle(pgObj, block, i) {
}
}

/**
* Create CTA button for trial or register and append to the nav tag ul
* @param {Object} xmlData.
*/
function decorateBlueButton(value, block) {
setTimeout(() => {
let href;
if (value.triallink.startsWith('#')) {
href = `${window.location.pathname}#trial`;
} else if (value.triallink.startsWith('/')) {
href = `${window.location.origin}${value.triallink}`;
} else if (value.triallink.startsWith('https://') || value.triallink.startsWith('http://')) {
href = value.triallink;
}
if (href) {
const trialBtn = domEl('calcite-button', { class: 'trial-button', href });
trialBtn.innerHTML = value.triallabel;
block.querySelector('nav > ul').appendChild(trialBtn);
}
}, 50);
}

/**
* For document authored paged title only 'function docAuthPageTitle()'.
* Normalize url path, replace origin if different current origin.
Expand All @@ -113,6 +135,9 @@ function parseXML(xmlData, block) {
if (key === 'pageTitle') {
appendPageTitle(xmlData[i], block, i);
}
if (value.triallabel) {
decorateBlueButton(value, block);
}
});
}
}
Expand Down Expand Up @@ -171,8 +196,6 @@ function initNavWrapper(block) {
const trialBtn = btnWrapper.lastElementChild;
mobileButton.setAttribute('aria-label', 'menu');
htmlNavTag.setAttribute('aria-label', 'main');
htmlNavTag.setAttribute('aria-expanded', 'false');
htmlNavTag.setAttribute('class', 'calcite-mode-dark');
htmlNavTag.id = 'main';
ul.classList.add('mobile-menu');
ul.setAttribute('aria-labelledby', 'nav-title');
Expand Down Expand Up @@ -201,6 +224,12 @@ function btnEventListener(block) {
mobileMenu.setAttribute('aria-expanded', 'false');
}
});
window.addEventListener('resize', () => {
if (window.innerWidth > 768) {
mobileBtn.setAttribute('icon', 'caret-down');
mobileMenu.setAttribute('aria-expanded', 'false');
}
});
}

/**
Expand All @@ -225,7 +254,6 @@ export default async function decorate(block) {
const PROXY = ISLOCAL.test(window.location.href) ? 'https://cors-anywhere.herokuapp.com/' : '';
const NAVAPI = 'https://www.esri.com/bin/esri/localnavigation';
const requestURL = `${PROXY}${NAVAPI}?path=/content/esri-sites${window.location.pathname}`;

await fetch(requestURL)
.then((response) => response.json())
.then((data) => {
Expand Down

0 comments on commit 4f37af9

Please sign in to comment.