Skip to content

Commit

Permalink
ADDED: video support in section block
Browse files Browse the repository at this point in the history
  • Loading branch information
sd-ditoy committed Jul 26, 2024
1 parent 876f2fc commit 20dc9fe
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 4 deletions.
89 changes: 87 additions & 2 deletions src/components/blocks/TextTeaser.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<div>
<h1 v-if="setAsH1" class="h1" v-html="boxTitle" :data-slug="slugged" />
<h2 v-else class="h1" v-html="boxTitle" :data-slug="slugged" />
<VideoPlayer
v-if="mergeVideo && hasVideo"
class=""
:thumb="video.thumbnail"
:provider="video.service"
:video-id="video.id"
/>
<p v-html="boxContent"></p>
<Button class="primary" v-if="hasButton">
<router-link v-if="button.type === 'int'" :to="`/${$i18n.locale}${button.url}`">
Expand All @@ -24,8 +31,15 @@
</Button>

</div>
<div>
<MediaImage v-if="image" :asset="image" />
<div v-if="!mergeVideo && (image || hasVideo)" :class="{ video: hasVideo }">
<div v-if="hasVideo" class="video-wrapper">
<VideoPlayer
:thumb="video.thumbnail"
:provider="video.service"
:video-id="video.id"
/>
</div>
<MediaImage v-else-if="image" :asset="image" />
</div>
</div>
</div>
Expand Down Expand Up @@ -83,6 +97,10 @@ export default {
type: Array,
default: null,
},
video: {
type: Object,
default: null,
},
variation: {
type: String,
default: 'text-left',
Expand Down Expand Up @@ -139,6 +157,10 @@ export default {
}
return null;
},
hasVideo() {
const { id } = this.video || {};
return !!id;
},
hasFile() {
const { file } = this;
return file && file.id && file.text;
Expand All @@ -151,6 +173,9 @@ export default {
const title = (this.boxTitle || '').replace(/<\/?[^>]+(>|$)/g, '');
return slugify(title, { lower: true, strict: true });
},
mergeVideo() {
return (this.$d.clientWidth <= 1241);
},
},
//---------------------------------------------------
//
Expand Down Expand Up @@ -242,6 +267,36 @@ export default {
max-width: 400px;
height: auto;
}
&.video {
align-self: flex-start;
& > .video-wrapper {
position: relative;
margin-top: 25px;
width: 100%;
height: auto;
aspect-ratio: 16/9;
& > .video-container {
padding: 0;
position: absolute;
top: 0;
left: 0;
width: 25vw;
min-width: 440px;
}
}
}
}
& > div:only-child {
display: block;
width: 100%;
margin: 0 auto;
.video-container {
padding: 5px 0;
}
}
@include breakpoint('sm') {
Expand Down Expand Up @@ -336,6 +391,36 @@ export default {
max-width: 400px;
height: auto;
}
&.video {
align-self: flex-start;
& > .video-wrapper {
position: relative;
width: 100%;
height: auto;
aspect-ratio: 16/9;
& > .video-container {
position: absolute;
padding: 0;
top: 0;
left: auto;
right: 0;
width: 25vw;
min-width: 440px;
}
}
}
}
& > div:only-child {
display: block;
width: 100%;
margin: 0 auto;
.video-container {
padding: 5px 0;
}
}
@include breakpoint('sm') {
Expand Down
5 changes: 3 additions & 2 deletions src/components/blocks/VideoPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ div[data-vimeo-initialized="true"] {
display: block;
left: 50%;
top: 50%;
width: 120px;
height: 120px;
width: 15%;
height: auto;
max-width: 120px;
z-index: 2000;
cursor: pointer;
backface-visibility: hidden;
Expand Down
1 change: 1 addition & 0 deletions src/views/PageFactory.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
:text-color="block.txtcolor"
:link-color="block.linkcolor"
:media="block.media"
:video="block.video"
:variation="block.variation"
/>
<Codeblock
Expand Down

0 comments on commit 20dc9fe

Please sign in to comment.