Skip to content

Commit

Permalink
[Release] Stage to Main (#2482)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-pr-merge[bot] authored Jun 19, 2024
2 parents ddbdf7a + 0428594 commit 02bf1a6
Show file tree
Hide file tree
Showing 9 changed files with 1,104 additions and 31 deletions.
2 changes: 1 addition & 1 deletion libs/blocks/adobetv/adobetv.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { applyHoverPlay, getVideoAttrs } from '../../utils/decorate.js';
const ROOT_MARGIN = 1000;

const loadAdobeTv = (a) => {
const bgBlocks = ['aside', 'marquee'];
const bgBlocks = ['aside', 'marquee', 'hero-marquee'];
if (a.href.includes('.mp4') && bgBlocks.some((b) => a.closest(`.${b}`))) {
a.classList.add('hide');
const { href, hash } = a;
Expand Down
34 changes: 8 additions & 26 deletions libs/blocks/brick/brick.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { decorateTextOverrides, decorateBlockText, decorateBlockBg, decorateIconStack, decorateButtons } from '../../utils/decorate.js';
import {
decorateBlockBg,
decorateBlockText,
decorateIconStack,
decorateTextOverrides,
decorateButtons,
handleObjectFit,
} from '../../utils/decorate.js';
import { createTag, getConfig, loadStyle } from '../../utils/utils.js';

const blockTypeSizes = {
large: ['xxl', 'm', 'l'],
default: ['xl', 'm', 'l'],
};
const objFitOptions = ['fill', 'contain', 'cover', 'none', 'scale-down'];

function getBlockSize(el) {
const sizes = Object.keys(blockTypeSizes);
Expand All @@ -21,30 +27,6 @@ function handleSupplementalText(foreground) {
if (lastP) lastP.className = 'supplemental-text';
}

function setObjectFitAndPos(text, pic, bgEl) {
const backgroundConfig = text.split(',').map((c) => c.toLowerCase().trim());
const fitOption = objFitOptions.filter((c) => backgroundConfig.includes(c));
const focusOption = backgroundConfig.filter((c) => !fitOption.includes(c));
if (fitOption) [pic.querySelector('img').style.objectFit] = fitOption;
bgEl.innerHTML = '';
bgEl.append(pic);
bgEl.append(document.createTextNode(focusOption.join(',')));
}

function handleObjectFit(bgRow) {
const bgConfig = bgRow.querySelectorAll('div');
[...bgConfig].forEach((r) => {
const pic = r.querySelector('picture');
if (!pic) return;
let text = '';
const pchild = [...r.querySelectorAll('p:not(:empty)')].filter((p) => p.innerHTML.trim() !== '');
if (pchild.length > 2) text = pchild[1]?.textContent.trim();
if (!text && r.textContent) text = r.textContent;
if (!text) return;
setObjectFitAndPos(text, pic, r);
});
}

function handleClickableBrick(el, foreground) {
if (!el.classList.contains('click')) return;
const links = foreground.querySelectorAll('.brick-text a');
Expand Down
Loading

0 comments on commit 02bf1a6

Please sign in to comment.