Skip to content

Commit

Permalink
make videos more responsive
Browse files Browse the repository at this point in the history
resolves #27
  • Loading branch information
AprilSylph committed Nov 14, 2022
1 parent 4082eb9 commit c8991f8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/lib/npf.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,21 @@ const blockRenderers = {
return figure;
},

video ({ url, media, embedHtml, embed_html = embedHtml, poster, attribution }) {
video ({
url,
media,
embedHtml,
embed_html = embedHtml,
embedIframe,
embed_iframe = embedIframe,
poster,
attribution
}) {
const figure = document.createElement('figure');
if (embed_iframe) {
const { width, height } = embed_iframe;
if (width && height) figure.style.setProperty('--aspect-ratio', `calc(${height} / ${width})`);
}

if (embed_html) {
Object.assign(figure, { innerHTML: embed_html });
Expand Down
5 changes: 3 additions & 2 deletions src/outbox.css
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,9 @@ article footer button {
text-transform: uppercase;
}

[data-block="video"] iframe[id="youtube_iframe"] {
height: calc(540px * (9/16));
[data-block="video"] iframe {
--post-width: min(540px, 100vw);
height: calc(var(--post-width) * var(--aspect-ratio, calc(9 / 16)));
}

[data-attribution="post"],
Expand Down

0 comments on commit c8991f8

Please sign in to comment.