Skip to content

Commit 4f37af9

Browse files
authored
Merge branch 'main' into localNavSubItems
2 parents 5007547 + 91c9f98 commit 4f37af9

File tree

3 files changed

+40
-5
lines changed

3 files changed

+40
-5
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
# Your Project's Title...
2-
Your project's description...
1+
# Adobe Edge for Esri Digital Experience
2+
3+
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.
34

45
## Environments
56
- Preview: https://main--esri-eds--esri.aem.page/

eds/blocks/local-navigation/local-navigation.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,10 @@
231231
.local-navigation calcite-icon {
232232
display: none;
233233
}
234+
235+
.local-navigation calcite-button {
236+
inline-size: auto;
237+
padding-inline: 0;
238+
padding-block: var(--space-3);
239+
}
234240
}

eds/blocks/local-navigation/local-navigation.js

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,28 @@ function appendPageTitle(pgObj, block, i) {
9999
}
100100
}
101101

102+
/**
103+
* Create CTA button for trial or register and append to the nav tag ul
104+
* @param {Object} xmlData.
105+
*/
106+
function decorateBlueButton(value, block) {
107+
setTimeout(() => {
108+
let href;
109+
if (value.triallink.startsWith('#')) {
110+
href = `${window.location.pathname}#trial`;
111+
} else if (value.triallink.startsWith('/')) {
112+
href = `${window.location.origin}${value.triallink}`;
113+
} else if (value.triallink.startsWith('https://') || value.triallink.startsWith('http://')) {
114+
href = value.triallink;
115+
}
116+
if (href) {
117+
const trialBtn = domEl('calcite-button', { class: 'trial-button', href });
118+
trialBtn.innerHTML = value.triallabel;
119+
block.querySelector('nav > ul').appendChild(trialBtn);
120+
}
121+
}, 50);
122+
}
123+
102124
/**
103125
* For document authored paged title only 'function docAuthPageTitle()'.
104126
* Normalize url path, replace origin if different current origin.
@@ -113,6 +135,9 @@ function parseXML(xmlData, block) {
113135
if (key === 'pageTitle') {
114136
appendPageTitle(xmlData[i], block, i);
115137
}
138+
if (value.triallabel) {
139+
decorateBlueButton(value, block);
140+
}
116141
});
117142
}
118143
}
@@ -171,8 +196,6 @@ function initNavWrapper(block) {
171196
const trialBtn = btnWrapper.lastElementChild;
172197
mobileButton.setAttribute('aria-label', 'menu');
173198
htmlNavTag.setAttribute('aria-label', 'main');
174-
htmlNavTag.setAttribute('aria-expanded', 'false');
175-
htmlNavTag.setAttribute('class', 'calcite-mode-dark');
176199
htmlNavTag.id = 'main';
177200
ul.classList.add('mobile-menu');
178201
ul.setAttribute('aria-labelledby', 'nav-title');
@@ -201,6 +224,12 @@ function btnEventListener(block) {
201224
mobileMenu.setAttribute('aria-expanded', 'false');
202225
}
203226
});
227+
window.addEventListener('resize', () => {
228+
if (window.innerWidth > 768) {
229+
mobileBtn.setAttribute('icon', 'caret-down');
230+
mobileMenu.setAttribute('aria-expanded', 'false');
231+
}
232+
});
204233
}
205234

206235
/**
@@ -225,7 +254,6 @@ export default async function decorate(block) {
225254
const PROXY = ISLOCAL.test(window.location.href) ? 'https://cors-anywhere.herokuapp.com/' : '';
226255
const NAVAPI = 'https://www.esri.com/bin/esri/localnavigation';
227256
const requestURL = `${PROXY}${NAVAPI}?path=/content/esri-sites${window.location.pathname}`;
228-
229257
await fetch(requestURL)
230258
.then((response) => response.json())
231259
.then((data) => {

0 commit comments

Comments
 (0)