<component class="video" v-slot="video" id="86jwyC1kFDk" is="video">
<div class="video__overlay" :class="{'video__overlay--active': video.active == true}">
<div class="video__btn">
<svg class="video__svg" viewBox="0 0 12 18">
<path d="M0 18V0l12 9.5L0 18Z" />
</svg>
</div>
<video class="video__loop object-cover" autoplay muted loop>
<source src="https://experience.brynathyn.edu/wp-content/themes/bryn-athyn/dist/videos/videoplayback2.mp4" type="video/mp4">
</video>
<picture>
<source media="(min-width:768px)" srcset="https://via.placeholder.com/960x540">
<img class="video__image object-cover" src="https://via.placeholder.com/960x540" alt="Test alt" />
</picture>
</div>
<div class="video__iframe"></div>
</component>
{% import "macros.twig" as macros %}
{% import "icons.twig" as icons %}
<component
class="video"
v-slot="video"
id="{{ video.id }}"
is="video"
>
<div
class="video__overlay"
:class="{'video__overlay--active': video.active == true}"
>
<div class="video__btn">
{{ icons.icon('play', 'video__svg') }}
</div>
{% if video.loop %}
<video class="video__loop object-cover" autoplay muted loop>
<source src="{{ video.loop }}" type="video/mp4">
</video>
{% endif %}
{{ macros.picture(
'video__image object-cover',
image.srcset,
image.src,
image.sizes.Rectangle,
image.sizes.Rectangle_mobile,
image.alt,
in_component_library
) }}
</div>
<div class="video__iframe"></div>
</component>
{
"in_component_library": true,
"image": {
"srcset": "https://via.placeholder.com/960x540",
"src": "https://via.placeholder.com/960x540",
"alt": "Test alt"
},
"video": {
"id": "86jwyC1kFDk",
"loop": "https://experience.brynathyn.edu/wp-content/themes/bryn-athyn/dist/videos/videoplayback2.mp4"
}
}
<template>
<div @click="toggleActive()" ref="video">
<slot
:active="active"
:setActive="setActive"
/>
</div>
</template>
<script>
import YTPlayer from 'yt-player';
export default {
data() {
return {
active: false,
player: null,
};
},
mounted() {
this.player = new YTPlayer(this.$refs.video.querySelector('.video__iframe'));
this.player.load(this.id);
},
props: {
id: {
type: String,
required: true,
},
},
methods: {
setActive() {
this.active = true;
this.player.play();
},
toggleActive() {
this.active = !this.active;
this.active ? this.player.play() : this.player.pause();
}
},
}
</script>
.video {
position: relative;
padding-bottom: 56.25%;
overflow: hidden;
&__overlay {
z-index: 10;
position: absolute;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
height: 100%;
cursor: pointer;
transition: $transition-default;
&:hover {
.video__btn {
transform: scale(1.2);
}
}
&--active {
visibility: hidden;
opacity: 0;
}
}
&__btn {
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
width: 80px;
height: 80px;
border-radius: 50%;
background-color: $red;
transition: $transition-default;
svg {
width: 16px;
fill: $black;
transform: translateX(2px);
}
}
&__loop {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
display: hidden;
min-width: 100%;
min-height: 100%;
background-repeat: repeat;
background-size: cover;
@include breakpoint(medium) {
display: block;
}
}
&__image {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
&__iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
}
No notes defined.