-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathYoutube.js
62 lines (46 loc) · 1.29 KB
/
Youtube.js
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*------------------------------------*\
#DEPENDENCIES
\*------------------------------------*/
import React, { Component } from 'react';
/*------------------------------------*\
#MODULE
\*------------------------------------*/
export class Youtube extends Component {
static defaultProps = {
autoPlay: 'false',
width: '560',
height: '315',
}
static propTypes = {
autoPlay: React.PropTypes.string,
width: React.PropTypes.string,
height: React.PropTypes.string,
videoId: React.PropTypes.string.isRequired
}
render() {
return (
<div style={styles.videoWrapper} className="videoWrapper">
<iframe style={styles.videoIframe} className="videoIframe" width={this.props.width} height={this.props.height} src={"https://www.youtube.com/embed/" + this.props.videoId + "?autoplay=" + this.props.autoPlay } frameBorder="0" allowFullScreen></iframe>
</div>
);
}
}
/*------------------------------------*\
#CSS STYLES
\*------------------------------------*/
const styles = {
videoWrapper: {
position: 'relative',
paddingBottom: '56.25%', /* ratio 16:9 */
height: '0',
maxWidth: '100%',
overflow: 'hidden'
},
videoIframe: {
position: 'absolute',
top: '0',
left: '0',
width: '100%',
height: '100%'
}
};