Skip to content

Commit 4d194fd

Browse files
authored
Add responsive youtube player component, hide related videos. (#85)
* Add responsive youtube player component, hide related videos. * Use correct case for YouTube
1 parent c07be69 commit 4d194fd

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

src/components/YoutubePlayer.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import styles from "@site/src/components/youTubePlayer.module.css";
3+
4+
type YouTubePlayerTypes = {
5+
videoId: string;
6+
};
7+
8+
const YouTubePlayer = ({ videoId }: YouTubePlayerTypes) => (
9+
<div className={styles.container}>
10+
<iframe
11+
allowFullScreen
12+
height="480"
13+
src={`https://www.youtube.com/embed/${videoId}?rel=0`}
14+
width="853"
15+
/>
16+
</div>
17+
);
18+
19+
export default YouTubePlayer;
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.container {
2+
position: relative;
3+
overflow: hidden;
4+
width: 100%;
5+
padding-top: 56.25%; /* 16:9 Aspect Ratio (divide 9 by 16 = 0.5625) */
6+
}
7+
8+
.container iframe {
9+
position: absolute;
10+
top: 0;
11+
left: 0;
12+
bottom: 0;
13+
right: 0;
14+
width: 100%;
15+
height: 100%;
16+
}

0 commit comments

Comments
 (0)