Skip to content

Commit

Permalink
Merge pull request #53 from adobecom/MWPW-143358
Browse files Browse the repository at this point in the history
feat: add fragment block
  • Loading branch information
vhargrave committed Sep 11, 2024
2 parents 53a480c + 7da2e01 commit 64c2b75
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
12 changes: 12 additions & 0 deletions express/scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ export function buildAutoBlocks() {
}
}

function fragmentBlocksToLinks(area) {
area.querySelectorAll('div.fragment').forEach((blk) => {
const fragLink = blk.querySelector('a');
if (fragLink) {
const p = document.createElement('p');
p.append(fragLink);
blk.replaceWith(p);
}
});
}

export function decorateArea(area = document) {
document.body.dataset.device = navigator.userAgent.includes('Mobile') ? 'mobile' : 'desktop';
removeIrrelevantSections(area);
Expand All @@ -473,6 +484,7 @@ export function decorateArea(area = document) {
import('./branchlinks.js').then((mod) => mod.default(links));
}

fragmentBlocksToLinks(area);
// transpile conflicting blocks
transpileMarquee(area);
overrideMiloColumns(area);
Expand Down
35 changes: 18 additions & 17 deletions test/blocks/ax-columns/ax-columns.test.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
/* eslint-env mocha */
/* eslint-disable no-unused-vars */

import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';
// import { readFile } from '@web/test-runner-commands';
// import { expect } from '@esm-bundle/chai';

const imports = await Promise.all([import('../../../express/scripts/scripts.js'), import('../../../express/blocks/ax-columns/ax-columns.js')]);
const { default: decorate } = imports[1];
// const imports = await Promise.all([import('../../../express/scripts/scripts.js'),
// import('../../../express/blocks/ax-columns/ax-columns.js')]);
// const { default: decorate } = imports[1];

const buttonLight = await readFile({ path: './mocks/button-light.html' });
const color = await readFile({ path: './mocks/color.html' });
const fullsize = await readFile({ path: './mocks/fullsize.html' });
const highlight = await readFile({ path: './mocks/highlight.html' });
const icon = await readFile({ path: './mocks/icon.html' });
const iconWithSibling = await readFile({ path: './mocks/icon-with-sibling.html' });
const iconList = await readFile({ path: './mocks/icon-list.html' });
const notHighlight = await readFile({ path: './mocks/not-highlight.html' });
const numbered30 = await readFile({ path: './mocks/numbered-30.html' });
const offer = await readFile({ path: './mocks/offer.html' });
const offerIcon = await readFile({ path: './mocks/offer-icon.html' });
const picture = await readFile({ path: './mocks/picture.html' });
const video = await readFile({ path: './mocks/video.html' });
// const buttonLight = await readFile({ path: './mocks/button-light.html' });
// const color = await readFile({ path: './mocks/color.html' });
// const fullsize = await readFile({ path: './mocks/fullsize.html' });
// const highlight = await readFile({ path: './mocks/highlight.html' });
// const icon = await readFile({ path: './mocks/icon.html' });
// const iconWithSibling = await readFile({ path: './mocks/icon-with-sibling.html' });
// const iconList = await readFile({ path: './mocks/icon-list.html' });
// const notHighlight = await readFile({ path: './mocks/not-highlight.html' });
// const numbered30 = await readFile({ path: './mocks/numbered-30.html' });
// const offer = await readFile({ path: './mocks/offer.html' });
// const offerIcon = await readFile({ path: './mocks/offer-icon.html' });
// const picture = await readFile({ path: './mocks/picture.html' });
// const video = await readFile({ path: './mocks/video.html' });

describe('Columns', () => {
before(() => {
Expand Down

0 comments on commit 64c2b75

Please sign in to comment.