Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {Component, Prop, h, Element} from '@stencil/core';
import {HeadingVarians} from '../../utils/utils';
@Component({
tag: 'hy-video',
styleUrl: 'hy-video.scss',
shadow: false,
})
export class HyVideo {
@Element() el: HTMLElement;
/** Video title */
@Prop() videoTitle: string;
/** Video description */
@Prop() videoDescription: string;
/** Context label */
@Prop() contextLabel: string;
/** Should context label be visible */
@Prop() contextLabelVisible: boolean = false;
/** Preview image url */
@Prop() previewImageUrl: string;
/** Url to video, used with preview image */
@Prop() linkToVideo: string;
/** Label for play button if preview image is provided */
@Prop() playButtonLabel: string;
/** Should play button be visible */
@Prop() playButtonVisible: boolean = false;
/** Views count number */
@Prop() views: string;
/** Label for views number */
@Prop() viewsLabel: string;
/** Duration number */
@Prop() duration: string;
/** Label for duration number */
@Prop() durationLabel: string;
/** Date added date as string */
@Prop() dateAdded: string;
/** Label for date added */
@Prop() dateAddedLabel: string;
/** Use horizontal layout where metadata is on side */
@Prop() horizontal: boolean = false;
@Prop() headerstyle: string = 'default';
componentDidLoad() {
let hyMainDiv = this.el.closest('.hy-main');
if (hyMainDiv) {
if (!hyMainDiv.classList.contains('with-sidebar')) {
this.headerstyle = 'large';
}
}
}
renderPreviewWithLink = () => {
return this.linkToVideo ? (
<a title={this.videoTitle} href={this.linkToVideo} class="hy-video__link-to-video">
<img class="hy-video__preview-image" src={this.previewImageUrl} alt={this.videoTitle} />
</a>
) : (
<img class="hy-video__preview-image" src={this.previewImageUrl} alt={this.videoTitle} />
);
};
renderPlayButton = () => {
return (
<span class="hy-video__play">
<button type="button">
<hy-icon icon={'hy-icon-video'} class={'hy-video__play-icon'} size={20} />
<span class="hy-video__button-label">{this.playButtonLabel}</span>
</button>
</span>
);
};
render() {
const classAttributes = [
'hy-video',
this.horizontal ? 'hy-video--horizontal' : '',
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<div class={classAttributes}>
<div class="hy-video__video-container">
{this.previewImageUrl ? (
<div>
{this.renderPreviewWithLink()}
<slot name="video"></slot>
</div>
) : (
<slot name="video"></slot>
)}
{this.playButtonVisible && this.renderPlayButton()}
{this.contextLabelVisible && <span class="hy-video__label">{this.contextLabel}</span>}
</div>
<div class="hy-video__meta">
{this.videoTitle && (
<hy-heading class="hy-video__meta__title" heading={HeadingVarians.h2}>
{this.videoTitle}
</hy-heading>
)}
{(this.duration || this.views || this.dateAdded) && (
<div class="hy-video__meta__details">
{this.duration && (
<div class="hy-video__meta__details--item">
<span class="hy-video__meta__label">{this.durationLabel}</span>
<span class="hy-video__meta__content">{this.duration}</span>
</div>
)}
{this.views && (
<div class="hy-video__meta__details--item">
<span class="hy-video__meta__label">{this.viewsLabel}</span>
<span class="hy-video__meta__content">{this.views}</span>
</div>
)}
{this.dateAdded && (
<div class="hy-video__meta__details--item">
<span class="hy-video__meta__label">{this.dateAddedLabel}</span>
<span class="hy-video__meta__content">{this.dateAdded}</span>
</div>
)}
</div>
)}
{this.videoDescription && <div class="hy-video__meta__description">{this.videoDescription}</div>}
</div>,
<hy-box mb="1.75, 1.75, 2, 2.5" />,
];