Skip to content

Commit 8025cb7

Browse files
authored
Revert "MWPW-161273 Standalone Gnav needs a release cycle [Bundle] (#… (adobecom#3319)
Revert "MWPW-161273 Standalone Gnav needs a release cycle [Bundle] (adobecom#3132)" This reverts commit f2fbeaa.
1 parent 218ae53 commit 8025cb7

27 files changed

+58
-750
lines changed

.eslintrc-code-compatibility.js

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
],
1515
ignorePatterns: [
1616
'/libs/deps/*',
17-
'/libs/navigation/dist/*',
1817
'/tools/loc/*',
1918
],
2019
};

.eslintrc.js

-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ module.exports = {
6262
'/libs/features/mas/*',
6363
'/tools/loc/*',
6464
'/libs/features/spectrum-web-components/*',
65-
'/libs/navigation/dist/*',
6665
],
6766
plugins: [
6867
'chai-friendly',

.github/workflows/release-standalone-feds.yml

-55
This file was deleted.

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@ logs/*
1111
test-html-results/
1212
test-results/
1313
test-a11y-results/
14-
libs/navigation/dist/

libs/blocks/global-footer/global-footer.css

-14
Original file line numberDiff line numberDiff line change
@@ -252,20 +252,6 @@
252252
height: 12px;
253253
}
254254

255-
@media (min-width: 600px) {
256-
dialog.feds-dialog {
257-
max-width: 80vw;
258-
width: fit-content;
259-
}
260-
}
261-
262-
@media (min-width: 1200px) {
263-
dialog.feds-dialog {
264-
width: 1200px;
265-
max-width: calc((100% - 6px) - 2em);
266-
}
267-
}
268-
269255
@media (min-width: 900px) {
270256
/* If there is too much content, float it on multiple rows */
271257
.feds-footer-wrapper .feds-menu-content {

libs/blocks/global-footer/global-footer.js

+6-34
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import {
44
decorateLinks,
55
getMetadata,
66
getConfig,
7+
loadBlock,
78
localizeLink,
8-
loadStyle,
99
} from '../../utils/utils.js';
1010

1111
import {
@@ -217,8 +217,6 @@ class Footer {
217217
</svg>
218218
${regionPickerTextElem}
219219
</a>`;
220-
regionPickerElem.dataset.modalPath = `${url.pathname}#_inline`;
221-
regionPickerElem.dataset.modalHash = url.hash;
222220
const regionPickerWrapperClass = 'feds-regionPicker-wrapper';
223221
this.elements.regionPicker = toFragment`<div class="${regionPickerWrapperClass}">
224222
${regionPickerElem}
@@ -232,48 +230,24 @@ class Footer {
232230
// Hash -> region selector opens a modal
233231
decorateAutoBlock(regionPickerElem); // add modal-specific attributes
234232
// TODO remove logs after finding the root cause for the region picker 404s -> MWPW-143627
235-
regionPickerElem.href = url.hash;
236233
if (regionPickerElem.classList[0] !== 'modal') {
237234
lanaLog({
238235
message: `Modal block class missing from region picker pre loading the block; locale: ${locale}; regionPickerElem: ${regionPickerElem.outerHTML}`,
239236
tags: 'errorType=warn,module=global-footer',
240237
});
241238
}
242-
loadStyle(`${base}/blocks/modal/modal.css`);
243-
const { default: initModal } = await import('../modal/modal.js');
244-
const modal = await initModal(regionPickerElem);
245-
246-
const loadRegionNav = async () => {
247-
const block = document.querySelector('.region-nav');
248-
if (block && getConfig().standaloneGnav) {
249-
// on standalone the region-nav will fail to load automatically through
250-
// the modal calling fragment.js. In that case we will have data-failed=true
251-
// and we should manually load region nav
252-
// If that's not the case then we're not a standalone gnav
253-
// and we mustn't load region-nav twice.
254-
if (block.getAttribute('data-failed') !== 'true') return;
255-
block.classList.add('hide');
256-
loadStyle(`${base}/blocks/region-nav/region-nav.css`);
257-
const { default: initRegionNav } = await import('../region-nav/region-nav.js');
258-
initRegionNav(block);
259-
// decoratePlaceholders(block, getConfig());
260-
block.classList.remove('hide');
261-
}
262-
};
263-
264-
if (modal) await loadRegionNav(); // just in case the modal is already open
265-
239+
await loadBlock(regionPickerElem); // load modal logic and styles
266240
if (regionPickerElem.classList[0] !== 'modal') {
267241
lanaLog({
268242
message: `Modal block class missing from region picker post loading the block; locale: ${locale}; regionPickerElem: ${regionPickerElem.outerHTML}`,
269243
tags: 'errorType=warn,module=global-footer',
270244
});
271245
}
246+
// 'decorateAutoBlock' logic replaces class name entirely, need to add it back
247+
regionPickerElem.classList.add(regionPickerClass);
272248
regionPickerElem.addEventListener('click', () => {
273249
if (!isRegionPickerExpanded()) {
274250
regionPickerElem.setAttribute('aria-expanded', 'true');
275-
// wait for the modal to load before we load the region nav
276-
window.addEventListener('milo:modal:loaded', loadRegionNav, { once: true });
277251
}
278252
});
279253
// Set aria-expanded to false when region modal is closed
@@ -288,8 +262,7 @@ class Footer {
288262
regionSelector.href = localizeLink(regionSelector.href);
289263
decorateAutoBlock(regionSelector); // add fragment-specific class(es)
290264
this.elements.regionPicker.append(regionSelector); // add fragment after regionPickerElem
291-
const { default: initFragment } = await import('../fragment/fragment.js');
292-
await initFragment(regionSelector); // load fragment and replace original link
265+
await loadBlock(regionSelector); // load fragment and replace original link
293266
// Update aria-expanded on click
294267
regionPickerElem.addEventListener('click', (e) => {
295268
e.preventDefault();
@@ -298,15 +271,14 @@ class Footer {
298271
});
299272
// Close region picker dropdown on outside click
300273
document.addEventListener('click', (e) => {
301-
e.preventDefault();
302274
if (isRegionPickerExpanded()
303275
&& !e.target.closest(`.${regionPickerWrapperClass}`)) {
304276
regionPickerElem.setAttribute('aria-expanded', false);
305277
}
306278
});
307279
}
308280

309-
return this.elements.regionPicker;
281+
return this.regionPicker;
310282
};
311283

312284
decorateSocial = () => {

libs/blocks/global-navigation/base.css

+2-2
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@
118118
align-items: center;
119119
}
120120

121-
header.global-navigation.ready {
122-
visibility: visible !important;
121+
header.global-navigation {
122+
visibility: visible;
123123
}
124124

125125
/* Desktop styles */

libs/blocks/global-navigation/global-navigation.js

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint import/no-relative-packages: 0 */
21
/* eslint-disable no-async-promise-executor */
32
import {
43
getConfig,
@@ -21,6 +20,7 @@ import {
2120
isTangentToViewport,
2221
lanaLog,
2322
loadBaseStyles,
23+
loadBlock,
2424
loadDecorateMenu,
2525
rootPath,
2626
loadStyles,
@@ -222,7 +222,7 @@ const decorateProfileTrigger = async ({ avatar }) => {
222222
let keyboardNav;
223223
const setupKeyboardNav = async () => {
224224
keyboardNav = keyboardNav || new Promise(async (resolve) => {
225-
const { default: KeyboardNavigation } = await import('./utilities/keyboard/index.js');
225+
const KeyboardNavigation = await loadBlock('./keyboard/index.js');
226226
const instance = new KeyboardNavigation();
227227
resolve(instance);
228228
});
@@ -425,17 +425,17 @@ class Gnav {
425425
this.block.removeEventListener('keydown', this.loadDelayed);
426426
if (this.searchPresent()) {
427427
const [
428-
{ default: Search },
428+
Search,
429429
] = await Promise.all([
430-
import('./features/search/gnav-search.js'),
430+
loadBlock('../features/search/gnav-search.js'),
431431
loadStyles(rootPath('features/search/gnav-search.css')),
432432
]);
433433
this.Search = Search;
434434
}
435435

436436
if (!this.useUniversalNav) {
437-
const [{ default: ProfileDropdown }] = await Promise.all([
438-
import('./features/profile/dropdown.js'),
437+
const [ProfileDropdown] = await Promise.all([
438+
loadBlock('../features/profile/dropdown.js'),
439439
loadStyles(rootPath('features/profile/dropdown.css')),
440440
]);
441441
this.ProfileDropdown = ProfileDropdown;
@@ -540,7 +540,7 @@ class Gnav {
540540
const unavVersion = new URLSearchParams(window.location.search).get('unavVersion') || '1.3';
541541
await Promise.all([
542542
loadScript(`https://${environment}.adobeccstatic.com/unav/${unavVersion}/UniversalNav.js`),
543-
loadStyles(`https://${environment}.adobeccstatic.com/unav/${unavVersion}/UniversalNav.css`, true),
543+
loadStyles(`https://${environment}.adobeccstatic.com/unav/${unavVersion}/UniversalNav.css`),
544544
]);
545545

546546
const getChildren = () => {
@@ -910,7 +910,7 @@ class Gnav {
910910

911911
const menuLogic = await loadDecorateMenu();
912912

913-
await menuLogic.decorateMenu({
913+
menuLogic.decorateMenu({
914914
item,
915915
template,
916916
type: itemType,
@@ -1021,7 +1021,7 @@ class Gnav {
10211021
const breadcrumbsElem = this.block.querySelector('.breadcrumbs');
10221022
// Breadcrumbs are not initially part of the nav, need to decorate the links
10231023
if (breadcrumbsElem) decorateLinks(breadcrumbsElem);
1024-
const { default: createBreadcrumbs } = await import('./features/breadcrumbs/breadcrumbs.js');
1024+
const createBreadcrumbs = await loadBlock('../features/breadcrumbs/breadcrumbs.js');
10251025
this.elements.breadcrumbsWrapper = await createBreadcrumbs(breadcrumbsElem);
10261026
return this.elements.breadcrumbsWrapper;
10271027
};
@@ -1091,6 +1091,5 @@ export default async function init(block) {
10911091
const mepMartech = mep?.martech || '';
10921092
block.setAttribute('daa-lh', `gnav|${getExperienceName()}${mepMartech}`);
10931093
if (isDarkMode()) block.classList.add('feds--dark');
1094-
block.classList.add('ready');
10951094
return gnav;
10961095
}

libs/blocks/global-navigation/utilities/getUserEntitlements.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint import/no-relative-packages: 0 */
21
/* eslint-disable camelcase */
32
import { getConfig } from '../../../utils/utils.js';
43

libs/blocks/global-navigation/utilities/getUserEventHistory.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint import/no-relative-packages: 0 */
21
/* eslint-disable no-promise-executor-return, no-async-promise-executor */
32
import { getConfig } from '../../../utils/utils.js';
43

libs/blocks/global-navigation/utilities/utilities.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint import/no-relative-packages: 0 */
21
import {
32
getConfig, getMetadata, loadStyle, loadLana, decorateLinks, localizeLink,
43
} from '../../../utils/utils.js';
@@ -135,9 +134,7 @@ export function rootPath(path) {
135134
return url;
136135
}
137136

138-
export function loadStyles(url, override = false) {
139-
const { standaloneGnav } = getConfig();
140-
if (standaloneGnav && !override) return;
137+
export function loadStyles(url) {
141138
loadStyle(url, (e) => {
142139
if (e === 'error') {
143140
lanaLog({
@@ -158,8 +155,6 @@ export function isDarkMode() {
158155
// since they can be independent of each other.
159156
// CSS imports were not used due to duplication of file include
160157
export async function loadBaseStyles() {
161-
const { standaloneGnav } = getConfig();
162-
if (standaloneGnav) return;
163158
if (isDarkMode()) {
164159
new Promise((resolve) => { loadStyle(rootPath('base.css'), resolve); })
165160
.then(() => loadStyles(rootPath('dark-nav.css')));
@@ -169,6 +164,10 @@ export async function loadBaseStyles() {
169164
}
170165
}
171166

167+
export function loadBlock(path) {
168+
return import(path).then((module) => module.default);
169+
}
170+
172171
let cachedDecorateMenu;
173172
export async function loadDecorateMenu() {
174173
if (cachedDecorateMenu) return cachedDecorateMenu;
@@ -178,12 +177,15 @@ export async function loadDecorateMenu() {
178177
resolve = _resolve;
179178
});
180179

181-
const [menu] = await Promise.all([
182-
import('./menu/menu.js'),
180+
const [{ decorateMenu, decorateLinkGroup }] = await Promise.all([
181+
loadBlock('./menu/menu.js'),
183182
loadStyles(rootPath('utilities/menu/menu.css')),
184183
]);
185184

186-
resolve(menu.default);
185+
resolve({
186+
decorateMenu,
187+
decorateLinkGroup,
188+
});
187189
return cachedDecorateMenu;
188190
}
189191

libs/blocks/region-nav/region-nav.css

-4
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,6 @@
5656
column-count: 1;
5757
}
5858

59-
.region-nav.hide {
60-
display: none;
61-
}
62-
6359
@media (min-width: 600px) {
6460
.region-nav > div:nth-of-type(2) {
6561
column-count: 3;

libs/navigation/base.css

-1
This file was deleted.

libs/navigation/bootstrapper.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
/* eslint import/no-relative-packages: 0 */
2-
export default async function bootstrapBlock(initBlock, blockConfig) {
1+
export default async function bootstrapBlock(miloLibs, blockConfig) {
32
const { name, targetEl, layout, noBorder, jarvis } = blockConfig;
4-
const { getConfig, createTag, loadScript } = await import('../utils/utils.js');
3+
const { getConfig, createTag, loadLink, loadScript } = await import(`${miloLibs}/utils/utils.js`);
4+
const { default: initBlock } = await import(`${miloLibs}/blocks/${name}/${name}.js`);
5+
6+
const styles = [`${miloLibs}/blocks/${name}/${name}.css`, `${miloLibs}/navigation/navigation.css`];
7+
styles.forEach((url) => loadLink(url, { rel: 'stylesheet' }));
58

69
const setNavLayout = () => {
710
const element = document.querySelector(targetEl);
@@ -38,7 +41,7 @@ export default async function bootstrapBlock(initBlock, blockConfig) {
3841

3942
await initBlock(document.querySelector(targetEl));
4043
if (blockConfig.targetEl === 'footer') {
41-
const { loadPrivacy } = await import('../scripts/delayed.js');
44+
const { loadPrivacy } = await import(`${miloLibs}/scripts/delayed.js`);
4245
setTimeout(() => {
4346
loadPrivacy(getConfig, loadScript);
4447
}, blockConfig.delay);

0 commit comments

Comments
 (0)