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

fix: added EsLazyYoutube to play video on single click #1492

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
37 changes: 36 additions & 1 deletion es-design-system/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions es-design-system/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"path": "^0.12.7",
"prismjs": "^1.29.0",
"vue": "^2.7.14",
"vue-lazy-youtube-video": "^2.4.0",
"vue-server-renderer": "^2.7.14",
"vue-slider-component": "^3.2.24",
"vue-template-compiler": "^2.7.14",
Expand Down
96 changes: 79 additions & 17 deletions es-vue-base/src/lib-components/EsVideo.vue
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
<template>
<div>
<b-embed
<div class="EsLazyYoutube">
<es-card
v-if="showVideo"
allowfullscreen
aspect="16by9"
:src="autoplayUrl"
:title="altText"
type="iframe" />
class="EsLazyYoutube-button bg-transparent overflow-hidden p-0 position-relative w-100"
variant="interactive">
<LazyYoutubeVideo
allowfullscreen
ref="lazyYoutube"

Check warning on line 9 in es-vue-base/src/lib-components/EsVideo.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 16)

Attribute "ref" should go before "allowfullscreen"
autoplay="true"
class="pb-0 EsLazyYoutube-restrict w-100 h-100"
:style="videoStyles"
:src="autoplayUrl"
:title="altText" />
</es-card>
<es-card
v-else
class="EsVideo-button bg-transparent overflow-hidden p-0 position-relative w-100"
class="EsLazyYoutube-button bg-transparent overflow-hidden p-0 position-relative w-100"
variant="interactive"
@click="showVideo = true">
<slot
Expand All @@ -19,28 +25,30 @@
v-else-if="coverImageUrl"
:alt="altText"
sizes="md:530px sm:275px"
class="EsVideo-image d-block w-100"
class="EsLazyYoutube-image d-block w-100"
:src="coverImageUrl" />
<icon-video-play
class="EsVideo-icon position-absolute"
class="EsLazyYoutube-icon position-absolute"
width="74px"
height="54px" />
</es-card>
</div>
</template>

<script lang="js">
import { BImg, BEmbed } from 'bootstrap-vue';
// eslint-disable-next-line import/no-extraneous-dependencies
import LazyYoutubeVideo from 'vue-lazy-youtube-video';

Check failure on line 40 in es-vue-base/src/lib-components/EsVideo.vue

View workflow job for this annotation

GitHub Actions / ci (ubuntu-latest, 16)

Unable to resolve path to module 'vue-lazy-youtube-video'
import { BImg } from 'bootstrap-vue';
import EsCard from './EsCard.vue';
import IconVideoPlay from '../lib-icons/icon-video-play.vue';

export default ({
name: 'EsVideo',
name: 'EsLazyYoutube',
components: {
BImg,
BEmbed,
EsCard,
IconVideoPlay,
LazyYoutubeVideo,
},
props: {
altText: {
Expand Down Expand Up @@ -72,22 +80,76 @@
// but requires that the video owner upload non-auto-generated captions
return `${pieces[0]}?rel=0&autoplay=1&cc_load_policy=1&cc_lang_pref=en`;
},
videoStyles() {
return {
position: 'relative',
paddingBottom: '0 !important',
height: '100%',
width: '100%',
};
},
},
// eslint-disable-next-line max-len, no-param-reassign
watch: { showVideo(val) { if (val) { this.$nextTick(() => { const videoInner = this.$refs.lazyYoutube.$el.querySelector('.y-video__inner'); if (videoInner) { videoInner.style.paddingBottom = '0'; const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { if (mutation.attributeName === 'style') { mutation.target.style.paddingBottom = '0'; } }); }); observer.observe(videoInner, { attributes: true }); } }); } } },
});
</script>

<style lang="scss" scoped>
.EsVideo {
&-button,
&-image {
height: auto;
.EsLazyYoutube {
display: flex;
justify-content: center;
align-items: center;
&-button {
height: 100%;
padding-bottom: 0 !important;
position: relative;
width: 100%;
}

&-icon {
left: 50%;
padding-bottom: 0 !important;
top: 50%;
transform: translateX(-50%) translateY(-50%);
z-index: 2;
}
&-image,
&-restrict
&-iframe,
iframe
{
height: 100% !important;
left: 0 !important;
//object-fit: cover !important;
padding-bottom: 0 !important;
position: relative !important;
top: 0 !important;
width: 100% !important;
}
}
.y-video__inner {
height: 100% !important;
position: relative !important;
padding-bottom: 0 !important;
width: 100% !important;
}

.y-video__media {
height: 800px !important;
padding-bottom: 0 !important;
width: 800px !important;
}

.html5-video-player {
height: 800px !important;
padding-bottom: 0 !important;
width: 800px !important;
}

.movie_player {
height: 800px !important;
padding-bottom: 0 !important;
width: 800px !important;
}

</style>
Loading