-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ShortsVideoItem.tsx Add ShortsVideoItem.styles.ts Update VideoShorts.tsx Update HomepageVideos.tsx
- Loading branch information
1 parent
87e54f2
commit eda0294
Showing
12 changed files
with
102 additions
and
10 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,38 @@ | ||
import styled from "styled-components"; | ||
|
||
export const StyledShortsVideoItem = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
&:hover { | ||
cursor: pointer; | ||
} | ||
.videoItemTitle { | ||
font-size: 16px; | ||
margin-top: 0.7rem; | ||
margin-bottom: 0.3rem; | ||
} | ||
.details { | ||
font-size: 14px; | ||
color: ${({ theme: { grey3 } }) => grey3}; | ||
display: flex; | ||
align-items: center; | ||
gap: 0.2rem; | ||
} | ||
`; | ||
|
||
export const StyledShortsVideoThumbnail = styled.div<{ $isMenuSmall: boolean }>` | ||
height: 24.8rem; | ||
width: 100%; | ||
border-radius: 0.8rem; | ||
overflow: hidden; | ||
img { | ||
width: 100%; | ||
height: 100%; | ||
border-radius: inherit; | ||
object-fit: cover; | ||
} | ||
`; |
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,51 @@ | ||
import React, { useState } from "react"; | ||
import { useAppContext } from "../../context/App.context"; | ||
import { | ||
StyledShortsVideoItem, | ||
StyledShortsVideoThumbnail, | ||
} from "./ShortsVideoItem.styles"; | ||
import ReactPlayer from "react-player"; | ||
import { Video } from "pexels"; | ||
import { Text } from "../../utils/Text.styles"; | ||
import { getTitle } from "../../utils/videos"; | ||
|
||
interface IShortsVideoItemProps { | ||
video: Video; | ||
} | ||
|
||
const ShortsVideoItem = ({ video }: IShortsVideoItemProps) => { | ||
const [playTrailer, setPlayTrailer] = useState(false); | ||
const { isMenuSmall } = useAppContext(); | ||
const TITLE_LENGTH = 50; | ||
|
||
return ( | ||
<StyledShortsVideoItem | ||
onMouseOver={() => setPlayTrailer(true)} | ||
onMouseOut={() => setPlayTrailer(false)} | ||
> | ||
<StyledShortsVideoThumbnail $isMenuSmall={isMenuSmall}> | ||
{playTrailer ? ( | ||
<ReactPlayer | ||
width="100%" | ||
height="100%" | ||
controls={false} | ||
volume={1} | ||
muted={false} | ||
style={{ height: "100%", width: "100%" }} | ||
playing={playTrailer} | ||
url={video.video_files[0].link} | ||
/> | ||
) : ( | ||
<img src={video.image} alt="thumbnail" /> | ||
)} | ||
</StyledShortsVideoThumbnail> | ||
<Text className="videoItemTitle"> | ||
{getTitle(video.url).slice(0, TITLE_LENGTH)} | ||
{getTitle(video.url).length > TITLE_LENGTH && "..."} | ||
</Text> | ||
<Text className="details">{video.duration}M views</Text> | ||
</StyledShortsVideoItem> | ||
); | ||
}; | ||
|
||
export default ShortsVideoItem; |
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