Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-166689 Add video support to Article Header #3737

Open
wants to merge 1 commit into
base: stage
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion libs/blocks/article-header/article-header.css
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
background: yellow;
}

.article-feature-image {
.article-feature-image,
.article-feature-video {
padding: 0;
margin: auto;
width: 100%;
Expand All @@ -198,6 +199,11 @@
object-fit: cover;
}

.article-feature-video .video-container,
.article-feature-video video {
width: 100%;
}

@media (min-width: 480px) {
.article-title h1 {
font-size: var(--type-heading-l-size);
Expand All @@ -218,6 +224,17 @@
.article-byline .article-byline-sharing span:not(:last-child) {
margin-right: 8px;
}

.article-feature-video .milo-video,
.article-feature-video .embed-vimeo {
padding-bottom: 580px;
}

.article-feature-video lite-vimeo,
.article-feature-video video {
height: 580px;
width: 100%;
}
}

@media (min-width: 700px) {
Expand Down
13 changes: 11 additions & 2 deletions libs/blocks/article-header/article-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ function decorateFigure(el) {
el.lastElementChild.remove();
}

function decorateMedia(el) {
if (el.querySelector('picture')) {
decorateFigure(el);
return;
}

el.classList.add('article-feature-video');
}

export default async function init(blockEl) {
const childrenEls = Array.from(blockEl.children);
const categoryContainer = childrenEls[0];
Expand Down Expand Up @@ -214,8 +223,8 @@ export default async function init(blockEl) {
const shareBlock = await buildSharing();
bylineContainer.append(shareBlock);

const featureImgContainer = childrenEls[3];
decorateFigure(featureImgContainer);
const mediaContainer = childrenEls[3];
decorateMedia(mediaContainer);

document.addEventListener('milo:deferred', () => updateShareText(shareBlock));
}
7 changes: 7 additions & 0 deletions test/blocks/article-header/article-header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,11 @@ describe('article header', () => {
await init(document.body.querySelector('.article-header'));
expect(document.body.querySelector('.article-category a')).to.be.null;
});

it('supports a featured video', async () => {
document.body.innerHTML = await readFile({ path: './mocks/body-video.html' });
const el = document.body.querySelector('.article-header');
await init(el);
expect(el.querySelector('.article-feature-video video')).to.exist;
});
});
21 changes: 21 additions & 0 deletions test/blocks/article-header/mocks/body-video.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="article-header">
<div>
<div>
<p><a href="" data-topic-link="Adobe Life">Adobe Life</a></p>
</div>
</div>
<div>
<div>
<h1 id="connecting-external-data-sources-to-adobe-experience-manager-guides-is-now-a-breeze">Connecting external data sources to Adobe Experience Manager Guides is now a breeze</h1>
</div>
</div>
<div>
<div>
<p><a href="/test/blocks/article-header/mocks/adobe-communication-team">Adobe Communications Team</a></p>
<p>02-25-2025</p>
</div>
</div>
<div>
<div><video playsinline="" controls="" data-video-source=""></video></div>
</div>
</div>
Loading