Skip to content

Commit

Permalink
Merge branch 'stage' of github.com:adobecom/milo into MWPW-159374
Browse files Browse the repository at this point in the history
  • Loading branch information
yesil committed Nov 6, 2024
2 parents aa229f3 + 9cb0da1 commit ca1f4da
Show file tree
Hide file tree
Showing 22 changed files with 210 additions and 216 deletions.
7 changes: 3 additions & 4 deletions libs/blocks/library-config/library-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,7 @@ async function loadList(type, content, list) {
}
}

async function fetchLibrary(domain) {
const { searchParams } = new URL(window.location.href);
const suppliedLibrary = searchParams.get('library');
async function fetchLibrary(domain, suppliedLibrary) {
const library = suppliedLibrary || `${domain}${LIBRARY_PATH}`;
try {
const resp = await fetch(library);
Expand All @@ -129,8 +127,9 @@ async function getSuppliedLibrary() {
const { searchParams } = new URL(window.location.href);
const repo = searchParams.get('repo');
const owner = searchParams.get('owner');
const library = searchParams.get('library');
if (!repo || !owner) return null;
return fetchLibrary(`https://main--${repo}--${owner}.hlx.live`);
return fetchLibrary(`https://main--${repo}--${owner}.hlx.live`, library);
}

async function fetchAssetsData(path) {
Expand Down
7 changes: 5 additions & 2 deletions libs/blocks/merch-card/merch-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ div[class*="-merch-card"] > div,
color: var(--text-color);
}

.twp.merch-card .merch-card-price {
.merch-card .merch-card-price {
font-weight: 700;
margin: 0;
margin-top: 8px;
margin-bottom: 16px;
font-size: 18px;
line-height: 22.5px;
}

merch-card.special-offers del span[is="inline-price"] {
Expand Down
6 changes: 5 additions & 1 deletion libs/blocks/merch-card/merch-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ const parseTwpContent = async (el, merchCard) => {
};

const appendPaymentDetails = (element, merchCard) => {
if (element.firstChild.nodeType !== Node.TEXT_NODE) return;
if (element.firstChild?.nodeType !== Node.TEXT_NODE) return;
const paymentDetails = createTag('div', { class: 'payment-details' }, element.innerHTML);
const headingM = merchCard.querySelector('h4[slot="heading-m"]');
headingM?.append(paymentDetails);
Expand Down Expand Up @@ -204,6 +204,7 @@ const appendCalloutContent = (element, merchCard) => {
const parseContent = async (el, merchCard) => {
let bodySlotName = `body-${merchCard.variant !== MINI_COMPARE_CHART ? 'xs' : 'm'}`;
let headingMCount = 0;
let headingXsCount = 0;

if (merchCard.variant === MINI_COMPARE_CHART) {
bodySlotName = 'body-m';
Expand All @@ -229,6 +230,7 @@ const parseContent = async (el, merchCard) => {
let slotName = SLOT_MAP[merchCard.variant]?.[tagName] || SLOT_MAP_DEFAULT[tagName];
if (slotName) {
if (['H2', 'H3', 'H4', 'H5'].includes(tagName)) {
if (tagName === 'H3') headingXsCount += 1;
element.classList.add('card-heading');
if (merchCard.badgeText) {
element.closest('div[role="tabpanel"')?.classList.add('badge-merch-cards');
Expand All @@ -247,6 +249,8 @@ const parseContent = async (el, merchCard) => {
}
}
element.setAttribute('slot', slotName);
tagName = (headingXsCount === 1 && tagName === 'H3')
|| (merchCard.variant === MINI_COMPARE_CHART && slotName === 'heading-m') ? 'h3' : 'p';
const newElement = createTag(tagName);
Array.from(element.attributes).forEach((attr) => {
newElement.setAttribute(attr.name, attr.value);
Expand Down
3 changes: 1 addition & 2 deletions libs/blocks/merch-card/merch-offer-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ function createDynamicSlots(el, bodySlot) {
if (pricePlaceholder) {
pricePlaceholder.setAttribute('slot', 'price');
} else {
const tagName = isTWP ? 'p' : 'h5';
const priceSlot = createTag(tagName, { class: 'merch-card-price' });
const priceSlot = createTag('p', { class: 'merch-card-price' });
createTag('span', { slot: 'price', is: 'inline-price' }, null, { parent: priceSlot });
bodySlot.append(priceSlot);
}
Expand Down
3 changes: 2 additions & 1 deletion libs/blocks/modal/modal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-underscore-dangle */
/* eslint-disable import/no-cycle */
import { createTag, getMetadata, localizeLink, loadStyle, getConfig } from '../../utils/utils.js';
import { decorateSectionAnalytics } from '../../martech/attributes.js';

const FOCUSABLES = 'a:not(.hide-video), button, input, textarea, select, details, [tabindex]:not([tabindex="-1"]';
const CLOSE_ICON = `<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20">
Expand Down Expand Up @@ -179,7 +180,7 @@ export async function getModal(details, custom) {
closeModal(dialog);
}
});

decorateSectionAnalytics(dialog, `${id}-modal`, getConfig());
dialog.append(close);
document.body.append(dialog);
dialogLoadingSet.delete(id);
Expand Down
4 changes: 1 addition & 3 deletions libs/blocks/table/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@

.table.has-addon .row-heading .col.col-heading:not(.col-1) .buttons-wrapper {
align-items: flex-end;
height: 100%;
}

.table.has-addon p.body {
Expand All @@ -485,7 +484,6 @@
text-align: start;
font-style: normal;
font-weight: 400;
gap: var(--spacing-xxs);
color: black;
padding: 5px 10px;
box-sizing: border-box;
Expand All @@ -495,7 +493,7 @@
background-color: var(--color-gray-300);
}

.table.has-addon .addon-label :first-child {
.table.has-addon .addon-label .icon {
display: flex;
align-self: center;
}
Expand Down
13 changes: 9 additions & 4 deletions libs/blocks/table/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,19 @@ function handleAddOnContent(table) {
const [position, order, style] = addOn.innerText.split('-')
.filter((key) => key.toUpperCase() !== addOnKey).map((key) => key.toLowerCase());
if (!position || !order) return;
const indexAttr = 'data-col-index';
const dataIndex = 'data-col-index';
[...table.querySelector('.row-heading').children].forEach((headCol) => {
headCol.querySelector('.heading-content')?.classList.add('content');
const colIndex = headCol.getAttribute(indexAttr);
const colIndex = headCol.getAttribute(dataIndex);
if (colIndex <= 1) return; // skip the key column
const tagName = `${position}-${order}`;
const content = [...addOnRow.children]
.find((col) => col.getAttribute(indexAttr) === colIndex).childNodes;
const column = [...addOnRow.children].find((el) => el.getAttribute(dataIndex) === colIndex);
let content = column.childNodes;
const icon = column.querySelector('.icon');
if (style === 'label' && icon) {
const text = [...content].filter((node) => !node.classList?.contains('icon'));
content = [createTag('span', null, text), icon];
}
const tag = createTag('div', { class: tagName }, [...content].map((node) => node));
if (style) tag.classList.add(`addon-${style}`);
const el = headCol.querySelector(`.${position}`);
Expand Down
28 changes: 10 additions & 18 deletions libs/deps/mas/mas.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ca1f4da

Please sign in to comment.