Skip to content

Commit

Permalink
[Release] Stage to Main (#3072)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-pr-merge[bot] authored Oct 23, 2024
2 parents f18df4f + c30fa5b commit b6e139d
Show file tree
Hide file tree
Showing 142 changed files with 14,097 additions and 12,577 deletions.
10 changes: 9 additions & 1 deletion libs/blocks/caas-config/caas-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,10 @@ const defaultOptions = {
default: 'Default',
grow: 'Grow',
},
partialLoadEnabled: {
true: 'Enabled',
false: 'Disabled',
},
};

const getTagList = (root) => Object.entries(root).reduce((options, [, tag]) => {
Expand Down Expand Up @@ -344,6 +348,9 @@ const BasicsPanel = ({ tagsData }) => {
<${Select} options=${countryTags} prop="country" label="Country" sort />
<${Select} options=${languageTags} prop="language" label="Language" sort />`;

const partialLoadOptions = html`
<${Input} label="Partial Load Count" prop="partialLoadCount" type="number" />`;

return html`
<${Input} label="Collection Name" placeholder="Only used in the author link" prop="collectionName" type="text" />
<${Input} label="Collection Title" prop="collectionTitle" type="text" title="Enter a title, {placeholder}, or leave empty "/>
Expand All @@ -353,7 +360,8 @@ const BasicsPanel = ({ tagsData }) => {
<${Input} label="Total Cards to Show" prop="totalCardsToShow" type="number" />
<${Input} label="Auto detect country & lang" prop="autoCountryLang" type="checkbox" />
${!state.autoCountryLang && countryLangOptions}
<${Input} label="Partial Load Enabled" prop="partialLoadEnabled" options="${defaultOptions.partialLoadEnabled}" type="checkbox" />
${state.partialLoadEnabled && partialLoadOptions}
`;
};

Expand Down
6 changes: 6 additions & 0 deletions libs/blocks/caas/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ export const getConfig = async (originalState, strs = {}) => {
setCardBorders: state.setCardBorders,
showFooterDivider: state.showFooterDivider,
useOverlayLinks: state.useOverlayLinks,
partialLoadWithBackgroundFetch: {
enabled: state.partialLoadEnabled,
partialLoadCount: state.partialLoadCount,
},
collectionButtonStyle: state.collectionBtnStyle,
banner: {
register: {
Expand Down Expand Up @@ -819,6 +823,8 @@ export const defaultState = {
paginationQuantityShown: false,
paginationType: 'paginator',
paginationUseTheme3: false,
partialLoadEnabled: false,
partialLoadCount: 100,
placeholderUrl: '',
resultsPerPage: 5,
searchFields: [],
Expand Down
19 changes: 11 additions & 8 deletions libs/blocks/global-navigation/global-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getExperienceName,
getFedsPlaceholderConfig,
hasActiveLink,
isActiveLink,
icons,
isDesktop,
isTangentToViewport,
Expand Down Expand Up @@ -968,28 +969,30 @@ class Gnav {
let customLinkModifier = '';
let removeCustomLink = false;
const linkElem = item.querySelector('a');
const customLinksSection = item.closest('.link-group');
linkElem.className = 'feds-navLink';
linkElem.setAttribute('daa-ll', getAnalyticsValue(linkElem.textContent, index + 1));
if (itemHasActiveLink) {
linkElem.removeAttribute('href');
linkElem.setAttribute('role', 'link');
linkElem.setAttribute('aria-disabled', 'true');
linkElem.setAttribute('aria-current', 'page');
linkElem.setAttribute('tabindex', 0);
}

const customLinksSection = item.closest('.link-group');
if (customLinksSection) {
const removeLink = () => {
const url = new URL(linkElem.href);
linkElem.setAttribute('href', `${url.origin}${url.pathname}${url.search}`);
if (isActiveLink(linkElem)) {
linkElem.removeAttribute('href');
}
const linkHash = url.hash.slice(2);
return !this.customLinks.includes(linkHash);
};
[...customLinksSection.classList].splice(1).forEach((className) => {
customLinkModifier = ` feds-navItem--${className}`;
});
removeCustomLink = removeLink();
} else if (itemHasActiveLink) {
linkElem.removeAttribute('href');
linkElem.setAttribute('role', 'link');
linkElem.setAttribute('aria-disabled', 'true');
linkElem.setAttribute('aria-current', 'page');
linkElem.setAttribute('tabindex', 0);
}

const linkTemplate = toFragment`
Expand Down
12 changes: 7 additions & 5 deletions libs/blocks/global-navigation/utilities/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,20 +266,22 @@ export const [setDisableAEDState, getDisableAEDState] = (() => {
];
})();

export const [hasActiveLink, setActiveLink, getActiveLink] = (() => {
export const [hasActiveLink, setActiveLink, isActiveLink, getActiveLink] = (() => {
let activeLinkFound;
const { origin, pathname } = window.location;
const url = `${origin}${pathname}`;

return [
() => activeLinkFound,
(val) => { activeLinkFound = !!val; },
(el) => (el.href === url || el.href.startsWith(`${url}?`) || el.href.startsWith(`${url}#`)),
(area) => {
const disableAED = getDisableAEDState();
const isCustomLinks = area.closest('.link-group')?.classList.contains('mobile-only');
const disableAED = getDisableAEDState() || isCustomLinks;
if (disableAED || hasActiveLink() || !(area instanceof HTMLElement)) return null;
const { origin, pathname } = window.location;
const url = `${origin}${pathname}`;
const activeLink = [
...area.querySelectorAll('a:not([data-modal-hash])'),
].find((el) => (el.href === url || el.href.startsWith(`${url}?`) || el.href.startsWith(`${url}#`)));
].find(isActiveLink);

if (!activeLink) return null;

Expand Down
6 changes: 5 additions & 1 deletion libs/blocks/graybox/graybox.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@
position: fixed;
}

.gb-no-click {
pointer-events: none;
user-select: none;
}

.gb-no-click::after {
content: "";
height: 100%;
pointer-events: none;
position: absolute;
width: 100%;
z-index: var(--above-all);
Expand Down
14 changes: 12 additions & 2 deletions libs/blocks/how-to/how-to.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
padding: var(--spacing-xxl) 0;
display: grid;
grid-template-rows: 1fr;
align-items: center;
grid-template-areas:
"heading"
"list"
Expand Down Expand Up @@ -59,6 +60,10 @@ html[dir="rtl"] .how-to ol > li::before {
order: 3;
}

.how-to-media.how-to-media-large.video {
justify-self: auto;
}

.how-to-media-large {
height: auto;
min-height: auto;
Expand Down Expand Up @@ -109,11 +114,12 @@ html[dir="rtl"] .how-to ol > li::before {
/* Desktop video */
@media screen and (min-width: 1200px) {
.how-to .foreground.has-video {
column-gap: var(--spacing-m);
column-gap: var( --spacing-l-static);
grid-template-rows: 1fr;
grid-auto-rows: min-content;
grid-template-areas:
"heading heading"
"list list"
"list image";
}

.how-to.large-image .foreground.has-video,
Expand All @@ -124,4 +130,8 @@ html[dir="rtl"] .how-to ol > li::before {
"heading heading"
"list image"
}

.how-to-media.how-to-media-large.video {
width: 588px;
}
}
6 changes: 3 additions & 3 deletions libs/blocks/how-to/how-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const setJsonLd = (heading, description, mainImage, stepsLd) => {
};

const getImage = (el) => el.querySelector('picture') || el.querySelector('a[href$=".svg"');
const getVideo = (el) => el.querySelector('a[href*=".mp4"]');
const getVideo = (el) => el.querySelector('video') || el.querySelector('.milo-video');

const getHowToInfo = (el) => {
const infoDiv = el.querySelector(':scope > div > div');
Expand Down Expand Up @@ -112,7 +112,7 @@ const getHowToSteps = (el) => {
{ steps: [], images: {} },
);

el.children[1].remove();
el.children[1]?.remove();
return steps;
};

Expand All @@ -133,7 +133,7 @@ export default function init(el) {
}

if (mainVideo) {
const videoClass = `how-to-media${isLargeMedia ? ' how-to-media-large' : ''}`;
const videoClass = `how-to-media${isLargeMedia ? ' how-to-media-large video' : ''}`;
el.append(createTag('div', { class: videoClass }, mainVideo));
}

Expand Down
7 changes: 4 additions & 3 deletions libs/blocks/media/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ function decorateAvatar(el) {
function decorateQr(el) {
const text = el.querySelector('.text');
if (!text) return;
const appStore = text.children[(text.children.length - 1)];
const googlePlay = text.children[(text.children.length - 2)];
const appStore = text.children[(text.children.length - 1)]?.querySelector('a');
const googlePlay = text.children[(text.children.length - 2)]?.querySelector('a');
const qrImage = text.children[(text.children.length - 3)];
if (!qrImage || !appStore || !googlePlay) return;
qrImage.classList.add('qr-code-img');
appStore.classList.add('app-store');
appStore.textContent = '';
googlePlay.classList.add('google-play');
googlePlay.textContent = '';
qrImage.classList.add('qr-code-img');
}

export default async function init(el) {
Expand Down
140 changes: 121 additions & 19 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const PRICE_TEMPLATE_OPTICAL = 'optical';
export const PRICE_TEMPLATE_REGULAR = 'price';
export const PRICE_TEMPLATE_STRIKETHROUGH = 'strikethrough';
export const PRICE_TEMPLATE_ANNUAL = 'annual';

const PRICE_TEMPLATE_MAPPING = new Map([
['priceDiscount', PRICE_TEMPLATE_DISCOUNT],
[PRICE_TEMPLATE_DISCOUNT, PRICE_TEMPLATE_DISCOUNT],
Expand Down Expand Up @@ -44,6 +45,105 @@ export const CC_SINGLE_APPS = [
['XD'],
];

const GeoMap = {
ar: 'AR_es',
be_en: 'BE_en',
be_fr: 'BE_fr',
be_nl: 'BE_nl',
br: 'BR_pt',
ca: 'CA_en',
ch_de: 'CH_de',
ch_fr: 'CH_fr',
ch_it: 'CH_it',
cl: 'CL_es',
co: 'CO_es',
la: 'DO_es',
mx: 'MX_es',
pe: 'PE_es',
africa: 'MU_en',
dk: 'DK_da',
de: 'DE_de',
ee: 'EE_et',
eg_ar: 'EG_ar',
eg_en: 'EG_en',
es: 'ES_es',
fr: 'FR_fr',
gr_el: 'GR_el',
gr_en: 'GR_en',
ie: 'IE_en',
il_he: 'IL_iw',
it: 'IT_it',
lv: 'LV_lv',
lt: 'LT_lt',
lu_de: 'LU_de',
lu_en: 'LU_en',
lu_fr: 'LU_fr',
my_en: 'MY_en',
my_ms: 'MY_ms',
hu: 'HU_hu',
mt: 'MT_en',
mena_en: 'DZ_en',
mena_ar: 'DZ_ar',
nl: 'NL_nl',
no: 'NO_nb',
pl: 'PL_pl',
pt: 'PT_pt',
ro: 'RO_ro',
si: 'SI_sl',
sk: 'SK_sk',
fi: 'FI_fi',
se: 'SE_sv',
tr: 'TR_tr',
uk: 'GB_en',
at: 'AT_de',
cz: 'CZ_cs',
bg: 'BG_bg',
ru: 'RU_ru',
ua: 'UA_uk',
au: 'AU_en',
in_en: 'IN_en',
in_hi: 'IN_hi',
id_en: 'ID_en',
id_id: 'ID_in',
nz: 'NZ_en',
sa_ar: 'SA_ar',
sa_en: 'SA_en',
sg: 'SG_en',
cn: 'CN_zh-Hans',
tw: 'TW_zh-Hant',
hk_zh: 'HK_zh-hant',
jp: 'JP_ja',
kr: 'KR_ko',
za: 'ZA_en',
ng: 'NG_en',
cr: 'CR_es',
ec: 'EC_es',
pr: 'US_es', // not a typo, should be US
gt: 'GT_es',
cis_en: 'AZ_en',
cis_ru: 'AZ_ru',
sea: 'SG_en',
th_en: 'TH_en',
th_th: 'TH_th',
};

export function getMiloLocaleSettings(locale) {
const localePrefix = locale?.prefix || 'US_en';
const geo = localePrefix.replace('/', '') ?? '';
let [country = 'US', language = 'en'] = (
GeoMap[geo] ?? geo
).split('_', 2);

country = country.toUpperCase();
language = language.toLowerCase();

return {
language,
country,
locale: `${language}_${country}`,
};
}

/* Optional checkout link params that are appended to checkout urls as is */
export const CHECKOUT_ALLOWED_KEYS = [
'af',
Expand Down Expand Up @@ -433,33 +533,35 @@ export async function getCheckoutAction(offers, options, imsSignedInPromise, el)
/**
* Activates commerce service and returns a promise resolving to its ready-to-use instance.
*/
export async function initService(force = false) {
export async function initService(force = false, attributes = {}) {
if (force) {
initService.promise = undefined;
document.head.querySelector('mas-commerce-service')?.remove();
fetchEntitlements.promise = undefined;
fetchCheckoutLinkConfigs.promise = undefined;
}
const { env, commerce = {}, locale } = getConfig();
const { commerce, env: miloEnv, locale: miloLocale } = getConfig();
initService.promise = initService.promise ?? polyfills().then(async () => {
const { hostname, searchParams } = new URL(window.location.href);
let commerceLibPath = '../../deps/mas/commerce.js';
if (/hlx\.(page|live)$|localhost$|www\.stage\.adobe\.com$/.test(hostname)) {
const maslibs = searchParams.get('maslibs');
if (maslibs) {
commerceLibPath = `${getMasBase(hostname, maslibs)}/libs/commerce.js`;
await import('../../deps/mas/commerce.js');
const { language, locale } = getMiloLocaleSettings(miloLocale);
let service = document.head.querySelector('mas-commerce-service');
if (!service) {
service = createTag('mas-commerce-service', {
locale,
language,
...attributes,
...commerce,
});
if (miloEnv?.name !== 'prod') {
service.setAttribute('allow-override', '');
}
service.registerCheckoutAction(getCheckoutAction);
document.head.append(service);
await service.readyPromise;
service.imsSignedInPromise?.then((isSignedIn) => {
if (isSignedIn) fetchEntitlements();
});
}
const commerceLib = await import(commerceLibPath);
const service = await commerceLib.init(() => ({
env,
commerce,
locale,
}), () => ({ getCheckoutAction, force }));
service.imsSignedInPromise.then((isSignedIn) => {
if (isSignedIn) {
fetchEntitlements();
}
});
return service;
});
return initService.promise;
Expand Down
Loading

0 comments on commit b6e139d

Please sign in to comment.