From ca41ec0e41999a8a400a2d6a7572198056f03943 Mon Sep 17 00:00:00 2001 From: Nico Date: Mon, 30 May 2022 06:26:38 +0900 Subject: [PATCH 1/4] migrate YouTube component to Typescript --- src/components/{YouTube.js => YouTube.tsx} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/components/{YouTube.js => YouTube.tsx} (96%) diff --git a/src/components/YouTube.js b/src/components/YouTube.tsx similarity index 96% rename from src/components/YouTube.js rename to src/components/YouTube.tsx index bd01d37901d..2ac3266b568 100644 --- a/src/components/YouTube.js +++ b/src/components/YouTube.tsx @@ -25,7 +25,7 @@ const YouTube = ({ id, start, title }) => { width="100%" height="315" src={src} - frameborder="0" + frameBorder="0" title={title || "YouTube"} allow=" accelerometer; @@ -34,7 +34,7 @@ const YouTube = ({ id, start, title }) => { encrypted-media; gyroscope; picture-in-picture" - allowfullscreen + allowFullScreen > ) From c500d56fc61796ad8123f3ff2af1716ebb564707 Mon Sep 17 00:00:00 2001 From: Nico Date: Tue, 31 May 2022 01:16:30 +0900 Subject: [PATCH 2/4] addinterface --- src/components/YouTube.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/YouTube.tsx b/src/components/YouTube.tsx index 2ac3266b568..40da9dd185a 100644 --- a/src/components/YouTube.tsx +++ b/src/components/YouTube.tsx @@ -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 = ({ id, start, title }) => { const startQuery = parseInt(start) > 0 ? `?start=${start}` : "" const baseUrl = "https://www.youtube.com/embed/" const src = baseUrl + id + startQuery From b88bb540f1e434990068d0994ea7b73563362f73 Mon Sep 17 00:00:00 2001 From: Nico Date: Wed, 1 Jun 2022 10:11:57 +0900 Subject: [PATCH 3/4] make start prop optional --- src/components/YouTube.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/YouTube.tsx b/src/components/YouTube.tsx index 40da9dd185a..307073e72e7 100644 --- a/src/components/YouTube.tsx +++ b/src/components/YouTube.tsx @@ -18,7 +18,7 @@ const Figure = styled.figure` export interface IProps { id: string - start: string + start?: string title: string } From c17848dbfd62c42a3d2bbb1285b697ef1ba1847d Mon Sep 17 00:00:00 2001 From: Pablo Pettinari Date: Wed, 1 Jun 2022 10:25:06 -0300 Subject: [PATCH 4/4] make start and title optional --- src/components/YouTube.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/YouTube.tsx b/src/components/YouTube.tsx index 307073e72e7..9a45cc14f3c 100644 --- a/src/components/YouTube.tsx +++ b/src/components/YouTube.tsx @@ -19,10 +19,10 @@ const Figure = styled.figure` export interface IProps { id: string start?: string - title: string + title?: string } -const YouTube: React.FC = ({ id, start, title }) => { +const YouTube: React.FC = ({ id, start = "0", title = "YouTube" }) => { const startQuery = parseInt(start) > 0 ? `?start=${start}` : "" const baseUrl = "https://www.youtube.com/embed/" const src = baseUrl + id + startQuery @@ -33,7 +33,7 @@ const YouTube: React.FC = ({ id, start, title }) => { height="315" src={src} frameBorder="0" - title={title || "YouTube"} + title={title} allow=" accelerometer; autoplay;