Skip to content

Commit

Permalink
Merge branch 'stage' into MWPW-142798-autoset-height-fit-content
Browse files Browse the repository at this point in the history
  • Loading branch information
mirafedas committed Mar 11, 2024
2 parents 43b7236 + 2f212d1 commit b7126cc
Show file tree
Hide file tree
Showing 29 changed files with 348 additions and 116 deletions.
36 changes: 19 additions & 17 deletions libs/blocks/caas-marquee/caas-marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,28 @@ const SEGMENTS_MAP = {
},
},
prod: {
'b446a9cf-a45c-40a7-ae67-33c2cf7f0bf7': 'acrobat',
'389deb08-1522-46e5-ba26-1df898934f4f': 'adobecom',
'079734f3-b593-4c58-8805-592d71f88d95': 'apro-cart-abandoner',
'295bea12-8443-41c9-9da1-8f75df77dd80': 'business',
'235a97a1-bf2e-4e92-bf18-13a9bfcf6ec9': 'cc-lapsed',
'f6553238-548f-4e39-bfa4-b299caaca62e': 'commerce',
'f569e4f9-f20a-4d6e-ba95-2abe4facdd1b': 'creative-cloud',
'5114ecd1-d1ac-4caa-869c-5652ab83afed': 'express',
'1d33382e-0c2c-4d24-8b1f-08be98cee22a': 'firefly',
'3f27d856-bbdd-431b-9e8f-44f6fe0cfbd0': 'helpx',
'5b88bec0-99f2-4736-b2d8-4809463b7fbd': 'illustrator',
'3822c05b-8074-4629-b493-59cc12a78650': 'lightroom',
'5b5c991e-2633-4390-8ee4-e58931da088e': 'photoshop',
'395264bb-b584-45fa-af53-a4396e64838b': 'premiere',
'c02e9190-cc42-47cd-85c0-421924c47f2b': 'sign',
'9aba8c9e-dce9-427e-8122-a6c796ee2d03': 'stock',
source: {
'b446a9cf-a45c-40a7-ae67-33c2cf7f0bf7': 'acrobat',
'389deb08-1522-46e5-ba26-1df898934f4f': 'adobecom',
'079734f3-b593-4c58-8805-592d71f88d95': 'apro-cart-abandoner',
'295bea12-8443-41c9-9da1-8f75df77dd80': 'business',
'235a97a1-bf2e-4e92-bf18-13a9bfcf6ec9': 'cc-lapsed',
'f6553238-548f-4e39-bfa4-b299caaca62e': 'commerce',
'f569e4f9-f20a-4d6e-ba95-2abe4facdd1b': 'creative-cloud',
'5114ecd1-d1ac-4caa-869c-5652ab83afed': 'express',
'1d33382e-0c2c-4d24-8b1f-08be98cee22a': 'firefly',
'3f27d856-bbdd-431b-9e8f-44f6fe0cfbd0': 'helpx',
'5b88bec0-99f2-4736-b2d8-4809463b7fbd': 'illustrator',
'3822c05b-8074-4629-b493-59cc12a78650': 'lightroom',
'5b5c991e-2633-4390-8ee4-e58931da088e': 'photoshop',
'395264bb-b584-45fa-af53-a4396e64838b': 'premiere',
'c02e9190-cc42-47cd-85c0-421924c47f2b': 'sign',
'9aba8c9e-dce9-427e-8122-a6c796ee2d03': 'stock',
},
},
};

const ALLOY_TIMEOUT = 500;
const ALLOY_TIMEOUT = 750;

const WIDTHS = {
split: 1199,
Expand Down
4 changes: 3 additions & 1 deletion libs/blocks/chart/chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export function processMarkData(series, xUnit) {
}

export async function fetchData(link) {
const resp = await fetch(link.href.toLowerCase());
const { customFetch } = await import('../../utils/helpers.js');
const resp = await customFetch({ resource: link.href.toLowerCase(), withCacheRules: true })
.catch(() => ({}));

if (!resp.ok) return {};

Expand Down
4 changes: 3 additions & 1 deletion libs/blocks/fragment/fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export default async function init(a) {
return;
}

const resp = await fetch(`${a.href}.plain.html`);
const { customFetch } = await import('../../utils/helpers.js');
const resp = await customFetch({ resource: `${a.href}.plain.html`, withCacheRules: true })
.catch(() => ({}));

if (!resp.ok) {
window.lana?.log(`Could not get fragment: ${a.href}.plain.html`);
Expand Down
41 changes: 22 additions & 19 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,29 @@ export const osMap = {
iPhone: 'iOS',
};

export const LANGMAP = {
cs: ['cz'],
da: ['dk'],
de: ['at'],
en: ['africa', 'au', 'ca', 'ie', 'in', 'mt', 'ng', 'nz', 'sg', 'za'],
es: ['ar', 'cl', 'co', 'cr', 'ec', 'gt', 'la', 'mx', 'pe', 'pr'],
et: ['ee'],
ja: ['jp'],
ko: ['kr'],
nb: ['no'],
pt: ['br'],
sl: ['si'],
sv: ['se'],
uk: ['ua'],
zh: ['cn', 'tw'],
};

// signIn, decorateSignIn and decorateProfileTrigger can be removed if IMS takes over the profile
const signIn = () => {
if (typeof window.adobeIMS?.signIn !== 'function') return;
if (typeof window.adobeIMS?.signIn !== 'function') {
lanaLog({ message: 'IMS signIn method not available', tags: 'errorType=warn,module=gnav' });
return;
}

window.adobeIMS.signIn();
};
Expand Down Expand Up @@ -214,24 +234,7 @@ const closeOnClickOutside = (e) => {
}
};

const getUniversalNavLocale = (locale) => {
const LANGMAP = {
cs: ['cz'],
da: ['dk'],
de: ['at'],
en: ['africa', 'au', 'ca', 'ie', 'in', 'mt', 'ng', 'nz', 'sg', 'za'],
es: ['ar', 'cl', 'co', 'cr', 'ec', 'gt', 'la', 'mx', 'pe', 'pr'],
et: ['ee'],
ja: ['jp'],
ko: ['kr'],
nb: ['no'],
pt: ['br'],
sl: ['si'],
sv: ['se'],
uk: ['ua'],
zh: ['cn', 'tw'],
};

export const getUniversalNavLocale = (locale) => {
if (!locale.prefix || locale.prefix === '/') return 'en_US';
const prefix = locale.prefix.replace('/', '');
if (prefix.includes('_')) {
Expand Down
6 changes: 6 additions & 0 deletions libs/blocks/library-container-end/library-container-end.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

.library-container-end,
.section.masonry-layout .library-container-end[class*='grid-'] {
display: none;
}

.library-container-end::before {
display: block;
content: 'Library Container End';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
.library-container-start,
.section.masonry-layout .library-container-start[class*='grid-'] {
display: none;
}

.library-container-start::before {
display: block;
content: 'Library Container Start';
Expand Down
9 changes: 4 additions & 5 deletions libs/blocks/library-metadata/library-metadata.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.library-metadata {
margin: 24px auto;
display: block;
}

.library-metadata::before {
Expand All @@ -10,18 +11,16 @@
border-radius: 6px;
text-transform: uppercase;
font-weight: 700;
font-size: smaller;
color: #293c51;
padding: 6px 12px;
}

.library-meta-row {
background-color: #EFEFEF;
display: grid;
grid-template-columns: 1fr 1fr;
margin-top: 4px;
border-radius: 6px;
}

.library-meta-row {
background-color: #EFEFEF;
padding: 6px 12px;
border-radius: 6px;
}
12 changes: 12 additions & 0 deletions libs/blocks/library-metadata/library-metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,16 @@ export default function init(el) {
row.classList.add('library-meta-row');
row.firstElementChild.classList.add('library-meta-key');
});
// Fixes layout issue for groups of blocks using a grid layout
const section = el.closest('.section');
if (section.querySelector('.library-container-end')) {
const content = section.querySelector('.content');
section.insertAdjacentElement('afterend', el);

if (!content) return;
const reflowSection = document.createElement('div');
reflowSection.classList.add('section');
reflowSection.append(content);
section.insertAdjacentElement('beforebegin', reflowSection);
}
}
4 changes: 2 additions & 2 deletions libs/blocks/media/media.css
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,13 @@ div[class*="-up"] .media .foreground > .media-row {
.media.qr-code .app-store {
width: 135px;
max-width: 140px;
height: 50px;
height: 40px;
font-size: 19px;
align-items: center;
justify-content: center;
padding: 0;
display: inline-flex;
margin: var(--spacing-xxs) var(--spacing-s) 0 0;
margin: var(--spacing-xs) var(--spacing-s) 0 0;
}

.media.qr-code .google-play {
Expand Down
6 changes: 5 additions & 1 deletion libs/features/footer-promo.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createTag, getConfig } from '../utils/utils.js';
import { decorateSectionAnalytics } from '../martech/attributes.js';

async function getPromoFromTaxonomy(contentRoot) {
const NAME_KEY = 'Name';
Expand All @@ -25,7 +26,8 @@ async function getPromoFromTaxonomy(contentRoot) {
}

export default async function initFooterPromo(footerPromoTag, footerPromoType) {
const { locale: { contentRoot } } = getConfig();
const config = getConfig();
const { locale: { contentRoot } } = config;
let href = footerPromoTag && `${contentRoot}/fragments/footer-promos/${footerPromoTag}`;

if (footerPromoType === 'taxonomy') {
Expand All @@ -42,4 +44,6 @@ export default async function initFooterPromo(footerPromoTag, footerPromoType) {
document.querySelector('main > div:last-of-type').insertAdjacentElement('afterend', section);
await loadFragment(a);
section.classList.add('section');
const sections = document.querySelectorAll('main > div');
decorateSectionAnalytics(section, sections.length - 1, config);
}
29 changes: 25 additions & 4 deletions libs/features/georoutingv2/georoutingv2.css
Original file line number Diff line number Diff line change
@@ -1,15 +1,29 @@
.dialog-modal.locale-modal-v2 .georouting-wrapper {
display: block !important;
padding: 56px 24px 40px;
}

.dialog-modal.locale-modal-v2 {
background-image: url('/libs/features/georoutingv2/img/GeoModal_BG_Map_Mobile.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
overflow: hidden;
font-family: 'Adobe Clean', adobe-clean, 'Trebuchet MS', sans-serif;
}

.dialog-modal.locale-modal-v2 .georouting-bg {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
justify-content: center;
align-items: center;
z-index: -1;
}

.dialog-modal.locale-modal-v2 .georouting-bg svg {
width: 100%;
}

.dialog-modal.locale-modal-v2 .picker {
position: fixed;
margin-top: 2px;
Expand Down Expand Up @@ -128,6 +142,13 @@
@media (min-width: 480px) {
.dialog-modal.locale-modal-v2 {
background-image: url('/libs/features/georoutingv2/img/GeoModal_BG_Map_Tablet.png');
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}

.dialog-modal.locale-modal-v2 .georouting-bg {
display: none;
}
}

Expand Down
40 changes: 22 additions & 18 deletions libs/features/georoutingv2/georoutingv2.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,26 +235,30 @@ function buildContent(currentPage, locale, geoData, locales) {

async function getDetails(currentPage, localeMatches, geoData) {
const availableLocales = await getAvailableLocales(localeMatches);
if (availableLocales.length > 0) {
const georoutingWrapper = createTag('div', { class: 'georouting-wrapper fragment' });
currentPage.url = window.location.hash ? document.location.href : '#';
if (availableLocales.length === 1) {
const content = buildContent(currentPage, availableLocales[0], geoData);
georoutingWrapper.appendChild(content);
return georoutingWrapper;
}
const sortedLocales = availableLocales.sort((a, b) => a.languageOrder - b.languageOrder);
const tabsContainer = createTabsContainer(sortedLocales.map((l) => l.language));
georoutingWrapper.appendChild(tabsContainer);

sortedLocales.forEach((locale) => {
const content = buildContent(currentPage, locale, geoData, sortedLocales);
const tab = createTab(content, locale.language);
georoutingWrapper.appendChild(tab);
});
if (!availableLocales.length) return null;
const { innerWidth } = window;
let svgDiv = null;
if (innerWidth < 480) {
const { default: getMobileBg } = await import('./getMobileBg.js');
svgDiv = createTag('div', { class: 'georouting-bg' }, getMobileBg());
}
const georoutingWrapper = createTag('div', { class: 'georouting-wrapper fragment', style: 'display:none;' }, svgDiv);
currentPage.url = window.location.hash ? document.location.href : '#';
if (availableLocales.length === 1) {
const content = buildContent(currentPage, availableLocales[0], geoData);
georoutingWrapper.appendChild(content);
return georoutingWrapper;
}
return null;
const sortedLocales = availableLocales.sort((a, b) => a.languageOrder - b.languageOrder);
const tabsContainer = createTabsContainer(sortedLocales.map((l) => l.language));
georoutingWrapper.appendChild(tabsContainer);

sortedLocales.forEach((locale) => {
const content = buildContent(currentPage, locale, geoData, sortedLocales);
const tab = createTab(content, locale.language);
georoutingWrapper.appendChild(tab);
});
return georoutingWrapper;
}

async function showModal(details) {
Expand Down
13 changes: 13 additions & 0 deletions libs/features/georoutingv2/getMobileBg.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion libs/features/icons/icons.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ let fetched = false;
async function getSVGsfromFile(path) {
/* c8 ignore next */
if (!path) return null;
const resp = await fetch(path);
const { customFetch } = await import('../../utils/helpers.js');
const resp = await customFetch({ resource: path, withCacheRules: true })
.catch(() => ({}));
/* c8 ignore next */
if (!resp.ok) return null;
const miloIcons = {};
Expand Down
4 changes: 2 additions & 2 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ const consolidateObjects = (arr, prop) => arr.reduce((propMap, item) => {
return propMap;
}, {});

const matchGlob = (searchStr, inputStr) => {
export const matchGlob = (searchStr, inputStr) => {
const pattern = searchStr.replace(/\*\*/g, '.*');
const reg = new RegExp(`^${pattern}$`, 'i'); // devtool bug needs this backtick: `
const reg = new RegExp(`^${pattern}(\\.html)?$`, 'i'); // devtool bug needs this backtick: `
return reg.test(inputStr);
};

Expand Down
6 changes: 4 additions & 2 deletions libs/features/placeholders.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ const getPlaceholdersPath = (config, sheet) => {
return `${path}${query}`;
};

const fetchPlaceholders = (config, sheet) => {
const fetchPlaceholders = async (config, sheet) => {
const placeholdersPath = getPlaceholdersPath(config, sheet);
const { customFetch } = await import('../utils/helpers.js');

fetchedPlaceholders[placeholdersPath] = fetchedPlaceholders[placeholdersPath]
// eslint-disable-next-line no-async-promise-executor
|| new Promise(async (resolve) => {
const resp = await fetch(placeholdersPath).catch(() => ({}));
const resp = await customFetch({ resource: placeholdersPath, withCacheRules: true })
.catch(() => ({}));
const json = resp.ok ? await resp.json() : { data: [] };
if (json.data.length === 0) { resolve({}); return; }
const placeholders = {};
Expand Down
9 changes: 9 additions & 0 deletions libs/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,12 @@ export function updateLinkWithLangRoot(link) {
return link;
}
}

export async function customFetch({ resource, withCacheRules }) {
const options = {};
if (withCacheRules) {
const params = new URLSearchParams(window.location.search);
options.cache = params.get('cache') === 'off' ? 'reload' : 'default';
}
return fetch(resource, options);
}
Loading

0 comments on commit b7126cc

Please sign in to comment.