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

migrate YouTube component to Typescript #6499

Merged
merged 4 commits into from
Jun 1, 2022
Merged
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
15 changes: 11 additions & 4 deletions src/components/YouTube.js → src/components/YouTube.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ const Figure = styled.figure`
* e.g. For https://www.youtube.com/watch?v=H-O3r2YMWJ4&t=123 the `start` is 123 (which means 123 seconds)
* @returns Embedded YouTube video component
*/
const YouTube = ({ id, start, title }) => {

export interface IProps {
id: string
start?: string
title?: string
}

const YouTube: React.FC<IProps> = ({ id, start = "0", title = "YouTube" }) => {
const startQuery = parseInt(start) > 0 ? `?start=${start}` : ""
const baseUrl = "https://www.youtube.com/embed/"
const src = baseUrl + id + startQuery
Expand All @@ -25,16 +32,16 @@ const YouTube = ({ id, start, title }) => {
width="100%"
height="315"
src={src}
frameborder="0"
title={title || "YouTube"}
frameBorder="0"
title={title}
allow="
accelerometer;
autoplay;
clipboard-write;
encrypted-media;
gyroscope;
picture-in-picture"
allowfullscreen
allowFullScreen
></iframe>
</Figure>
)
Expand Down