Last active
June 21, 2020 08:51
-
-
Save pwign/9d8d84c74f7ef80383bd793bcaa0ff72 to your computer and use it in GitHub Desktop.
Responsive Vimeo embed for reading.supply articles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const NATURAL_NON_ABSOLUTE_ELEMENT = css` | |
display: flex; | |
white-space: wrap; | |
position: relative; | |
/* CHANGE THIS: The padding-top percentage depends on the video's aspect ratio. height / width */ | |
padding: 75% 0 0 0; | |
` | |
const CLASSIC_WEB_CSS_INVISIBLE_TEXT_HACK = css` | |
visibility: hidden; | |
opacity: 0; | |
height: 0px; | |
` | |
const IFRAME_STYLE_REPLACEMENT_REQUIRED = css` | |
position: absolute; | |
top: 0; | |
left: 0; | |
width: 100%; | |
height: 100%; | |
` | |
const element = ( | |
<div className={NATURAL_NON_ABSOLUTE_ELEMENT}> | |
<div className={CLASSIC_WEB_CSS_INVISIBLE_TEXT_HACK}> | |
{" "} | |
</div> | |
<iframe | |
src="https://player.vimeo.com/video/387376944?autoplay=1&loop=1&color=747cff&title=0&byline=0&portrait=0" | |
className={IFRAME_STYLE_REPLACEMENT_REQUIRED} | |
frameborder="0" | |
allow="autoplay; fullscreen" | |
allowfullscreen | |
></iframe> | |
</div> | |
) | |
render(element) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment