Skip to content

Commit

Permalink
Merge pull request #886 from adobecom/2445
Browse files Browse the repository at this point in the history
DC MILO Release 0.2445
  • Loading branch information
joaquinrivero authored Nov 5, 2024
2 parents 00191c9 + 67a2f43 commit aabc1b3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
27 changes: 17 additions & 10 deletions acrobat/blocks/prompt-card/prompt-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import { setLibs } from '../../scripts/utils.js';

const miloLibs = setLibs('/libs');
const { createTag } = await import(`${miloLibs}/utils/utils.js`);
const { processTrackingLabels } = await import(`${miloLibs}/martech/attributes.js`);
let createTag;
let processTrackingLabels;

const classToastShow = 'prompt-toast--show';
const getPlaceHolder = (x) => (window.mph?.[x] || x);
Expand All @@ -29,7 +29,8 @@ function copyPrompt(cfg) {
setTimeout(() => toast.classList.remove(classToastShow), 5000);
}

async function createBlock(element, cfg) {
function createBlock(el, cfg) {
const element = el || createTag('div', { class: 'prompt-card' });
cfg.icon = cfg.icon || '/acrobat/img/icons/aichat.svg';
cfg.button = cfg.button || getPlaceHolder('Copy');
cfg.toast = cfg.toast || getPlaceHolder('Copied to clipboard');
Expand Down Expand Up @@ -70,14 +71,15 @@ async function createBlock(element, cfg) {
copyPrompt(cfg);
}
});

return element;
}

async function createBlocks(element, blockArray, templateCfg) {
function createBlocks(element, blockArray, templateCfg) {
const { parentNode } = element;
for (const [i, cfg] of blockArray.entries()) {
const blockEl = createTag('div', { class: 'prompt-card' });
if (templateCfg?.rows && i > 0) blockEl.classList.add('hidden');
await createBlock(blockEl, { ...templateCfg, ...cfg });
for (const [idx, cfg] of blockArray.entries()) {
const blockEl = createBlock(null, { ...templateCfg, ...cfg });
if (templateCfg?.rows && idx > 0) blockEl.classList.add('hidden');
parentNode.insertBefore(blockEl, element.previousSibling);
}
element.remove();
Expand Down Expand Up @@ -133,7 +135,7 @@ async function processGroup(element, cfg, startIndex) {
(x) => keys.reduce((a, k) => a && cfg[k] === x[k], true),
);
}
await createBlocks(element, blockArray, cfg);
createBlocks(element, blockArray, cfg);
}

function readKeyValueSet(element) {
Expand All @@ -146,6 +148,11 @@ function readKeyValueSet(element) {
}

export default async function init(element) {
const { createTag: createTagfn } = await import(`${miloLibs}/utils/utils.js`);
const { processTrackingLabels: processTrackingLabelsfn } = await import(`${miloLibs}/martech/attributes.js`);
createTag = createTagfn;
processTrackingLabels = processTrackingLabelsfn;

if (element.classList.contains('template') && element.classList.contains('group')) {
const cfg = readKeyValueSet(element);
await processGroup(element, cfg, Object.keys(cfg).length + 1);
Expand All @@ -172,5 +179,5 @@ export default async function init(element) {

cfg = { ...window.promptCardTemplate, ...cfg };

await createBlock(element, cfg);
createBlock(element, cfg);
}
7 changes: 4 additions & 3 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,12 @@ replaceDotMedia(document);

// Default to loading the first image as eager.
(async function loadLCPImage() {
const marquee = document.querySelector('.marquee'); // first marquee only
const blocks = '.marquee,.hero-marquee';
const marquee = document.querySelector(blocks); // first marquee only
if (marquee) {
const index = window.browser.isMobile ? 1 : 3;
const selectorBG = `.marquee > div:nth-child(1) > div:nth-of-type(${index}) img`;
const selectorFG = '.marquee > div:nth-child(2) img';
const selectorBG = `${blocks} > div:nth-child(1) > div:nth-of-type(${index}) img`;
const selectorFG = `${blocks} > div:nth-child(2) img`;
marquee.querySelector(selectorBG)?.setAttribute('loading', 'eager');
marquee.querySelector(selectorFG)?.setAttribute('loading', 'eager');
}
Expand Down
6 changes: 0 additions & 6 deletions acrobat/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@ div [class *= PdfnowLifecycle__dropzone2___] {
padding: 0;
}

.feds-topnav .feds-brand-image img {
aspect-ratio: 1/1;
width: 100%;
object-fit: contain;
}

.how-to .how-to-image img {
aspect-ratio: 5/3;
width: 100%;
Expand Down

0 comments on commit aabc1b3

Please sign in to comment.