Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
180 additions
and
20 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
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
64 changes: 64 additions & 0 deletions
64
src/web/app/src/components/Posts/YouTubeInfo/YouTubeInfoMobile.tsx
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,64 @@ | ||
import { createStyles, makeStyles, Theme, ListSubheader } from '@material-ui/core'; | ||
import { AiOutlineYoutube } from 'react-icons/ai'; | ||
import { useYouTubeInfo } from '../../../hooks/use-genericInfo'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
padding: '0', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
[theme.breakpoints.up('lg')]: { | ||
width: '21rem', | ||
}, | ||
color: theme.palette.text.secondary, | ||
lineHeight: 'normal', | ||
}, | ||
link: { | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
'&:hover': { | ||
textDecorationLine: 'none', | ||
}, | ||
}, | ||
icon: { | ||
fontSize: '2rem', | ||
marginRight: '1rem', | ||
verticalAlign: 'text-bottom', | ||
}, | ||
YouTubeInfoContainer: { | ||
margin: '0 0 0 1rem', | ||
fontSize: '1.2rem', | ||
}, | ||
YouTubeTitleSection: { | ||
fontSize: '1.4rem', | ||
margin: 0, | ||
paddingTop: '1rem', | ||
lineHeight: 'normal', | ||
}, | ||
}) | ||
); | ||
|
||
const YouTubeInfoMobile = () => { | ||
const classes = useStyles(); | ||
|
||
const { channelUrl, subscriberCount, viewCount } = useYouTubeInfo(); | ||
|
||
return ( | ||
<ListSubheader component="div" className={classes.root}> | ||
{!!channelUrl && ( | ||
<div className={classes.YouTubeInfoContainer}> | ||
<h2 className={classes.YouTubeTitleSection}> | ||
<a href={channelUrl} className={classes.link}> | ||
<AiOutlineYoutube className={classes.icon} /> Channel | ||
</a> | ||
</h2> | ||
<p>{subscriberCount} subscribers</p> | ||
<p>{viewCount} views</p> | ||
</div> | ||
)} | ||
</ListSubheader> | ||
); | ||
}; | ||
|
||
export default YouTubeInfoMobile; |
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,65 @@ | ||
import { createStyles, makeStyles, Theme, ListSubheader } from '@material-ui/core'; | ||
import { AiOutlineYoutube } from 'react-icons/ai'; | ||
import { useYouTubeInfo } from '../../../hooks/use-genericInfo'; | ||
|
||
const useStyles = makeStyles((theme: Theme) => | ||
createStyles({ | ||
root: { | ||
padding: '0', | ||
display: 'flex', | ||
borderLeft: '1.5px solid #999999', | ||
flexDirection: 'column', | ||
[theme.breakpoints.up('lg')]: { | ||
width: '21rem', | ||
}, | ||
color: theme.palette.text.secondary, | ||
lineHeight: 'normal', | ||
}, | ||
link: { | ||
textDecoration: 'none', | ||
color: 'inherit', | ||
'&:hover': { | ||
textDecorationLine: 'none', | ||
}, | ||
}, | ||
icon: { | ||
fontSize: '2rem', | ||
marginRight: '1rem', | ||
verticalAlign: 'text-bottom', | ||
}, | ||
YouTubeInfoContainer: { | ||
margin: '2rem 0 0 1rem', | ||
fontSize: '1.2rem', | ||
}, | ||
YouTubeTitleSection: { | ||
fontSize: '1.4rem', | ||
margin: 0, | ||
paddingTop: '1rem', | ||
lineHeight: 'normal', | ||
}, | ||
}) | ||
); | ||
|
||
const YouTubeInfo = () => { | ||
const classes = useStyles(); | ||
|
||
const { channelUrl, subscriberCount, viewCount } = useYouTubeInfo(); | ||
|
||
return ( | ||
<ListSubheader component="div" className={classes.root}> | ||
{!!channelUrl && ( | ||
<div className={classes.YouTubeInfoContainer}> | ||
<h2 className={classes.YouTubeTitleSection}> | ||
<a href={channelUrl} className={classes.link}> | ||
<AiOutlineYoutube className={classes.icon} /> Channel | ||
</a> | ||
</h2> | ||
<p>{subscriberCount} subscribers</p> | ||
<p>{viewCount} views</p> | ||
</div> | ||
)} | ||
</ListSubheader> | ||
); | ||
}; | ||
|
||
export default YouTubeInfo; |
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,23 @@ | ||
import { Post } from '../interfaces'; | ||
|
||
export interface YouTubeInfoContextInterface { | ||
channelUrl: string; | ||
subscriberCount: number; | ||
viewCount: number; | ||
} | ||
|
||
export const extractYouTubeInfo = (post: Post): YouTubeInfoContextInterface => { | ||
const youTubeInfo = { | ||
channelUrl: '', | ||
subscriberCount: -1, | ||
viewCount: -1, | ||
}; | ||
|
||
if (post.type !== 'video') { | ||
return youTubeInfo; | ||
} | ||
|
||
youTubeInfo.channelUrl = post.feed.link; | ||
|
||
return youTubeInfo; | ||
}; |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { useContext } from 'react'; | ||
import { GitHubInfoContextInterface } from '../components/GitHubInfo'; | ||
import { YouTubeInfoContextInterface } from '../components/YouTubeInfo'; | ||
import { GenericInfoContext } from '../components/GenericInfoProvider'; | ||
|
||
const useGithubInfo = (): GitHubInfoContextInterface => useContext(GenericInfoContext).gitHubInfo; | ||
|
||
export default useGithubInfo; | ||
export const useGithubInfo = (): GitHubInfoContextInterface => | ||
useContext(GenericInfoContext).gitHubInfo; | ||
export const useYouTubeInfo = (): YouTubeInfoContextInterface => | ||
useContext(GenericInfoContext).youTubeInfo; |