-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #109 from kachun333/css-enhancement
Css enhancement
- Loading branch information
Showing
5 changed files
with
158 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import Skeleton from "@mui/material/Skeleton"; | ||
import React, { useState } from "react"; | ||
import YouTube, { YouTubeEvent } from "react-youtube"; | ||
|
||
interface WrappedVideoProps { | ||
videoId: string; | ||
} | ||
|
||
const WrappedVideo: React.FC<WrappedVideoProps> = ({ videoId }) => { | ||
const [isReady, setIsReady] = useState(false); | ||
|
||
const opts = { | ||
height: 195, | ||
width: 320, | ||
}; | ||
|
||
const onReady = (event: YouTubeEvent<any>) => { | ||
setIsReady(true); | ||
// access to player in all event handlers via event.target | ||
event.target.pauseVideo(); | ||
}; | ||
|
||
const ytDisplay = isReady ? undefined : "none"; | ||
|
||
return ( | ||
<> | ||
{!isReady && ( | ||
<Skeleton | ||
variant="rectangular" | ||
height={opts.height} | ||
width={opts.width} | ||
/> | ||
)} | ||
<YouTube | ||
style={{ display: ytDisplay }} | ||
videoId={videoId} | ||
opts={opts} | ||
onReady={onReady} | ||
/> | ||
</> | ||
); | ||
}; | ||
|
||
export default WrappedVideo; |