-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added lazy loading for all images and custom lazy loading for the YouTube video player on the workshops page * Updated comment detailing what YouTube format needs to look like * Added animations for lazy loading, used CSS to show video controls for workshop page * Fixed header issue with workshop page * Fixed gray border underneath workshop video thumbnails * Change background color to transparent
- Loading branch information
Showing
12 changed files
with
228 additions
and
78 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,73 @@ | ||
import React from 'react'; | ||
import '../../styles/Workshops.css'; | ||
import ReactPlayer from 'react-player/youtube'; | ||
import { Github, Youtube, File } from '@geist-ui/icons'; | ||
|
||
|
||
export default function Workshop({ title, youtube, author, description, readme, slides}) { | ||
|
||
|
||
const README = readme ? | ||
<button className='workshop-button'> | ||
<Github color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={readme} target='_blank' rel='noreferrer'>Readme</a> | ||
</button> : null; | ||
|
||
const SLIDES = slides ? | ||
<button className='workshop-button'> | ||
<File color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={slides} target='_blank' rel='noreferrer'>Slides</a> | ||
</button> : null; | ||
return ( | ||
<div className='workshop-container'> | ||
<ReactPlayer | ||
className='workshop-video' | ||
id={'id_' + title.replace(/ /g, '_')} | ||
controls={true} | ||
width='100%' | ||
url={youtube} /> | ||
<hgroup className='workshop-header'> | ||
<h3 className='workshop-title'>{title}</h3> | ||
<h4 className='workshop-author'>Taught by: {author}</h4> | ||
</hgroup> | ||
<p className='workshop-description'>{description}</p> | ||
<div className='workshop-links'> | ||
<button className='workshop-button'> | ||
<Youtube color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={youtube} target='_blank' rel='noreferrer'>Video</a> | ||
</button> | ||
{README} | ||
{SLIDES} | ||
</div> | ||
</div> | ||
); | ||
import React, {useState} from 'react'; | ||
import '../../styles/Workshops.css'; | ||
import ReactPlayer from 'react-player/youtube'; | ||
import { Github, Youtube, File } from '@geist-ui/icons'; | ||
import { LazyLoadImage } from 'react-lazy-load-image-component'; | ||
|
||
|
||
export default function Workshop({ title, youtube, author, description, readme, slides}) { | ||
|
||
const [isPlayerVisible, setIsPlayerVisible] = useState(false); | ||
|
||
const README = readme ? | ||
<button className='workshop-button'> | ||
<Github color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={readme} target='_blank' rel='noreferrer'> Readme</a> | ||
</button> : null; | ||
|
||
const SLIDES = slides ? | ||
<button className='workshop-button'> | ||
<File color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={slides} target='_blank' rel='noreferrer'> Slides</a> | ||
</button> : null; | ||
return ( | ||
<div className='workshop-container'> | ||
|
||
{/* Lazy loads thumbnail images | ||
video player is not actually loaded until a thumbnail is clicked */} | ||
<div className='video-container'> | ||
{!isPlayerVisible ? ( | ||
<> | ||
<LazyLoadImage | ||
className='video-thumbnail' | ||
src={`https://img.youtube.com/vi/${youtube.split('/').pop()}/0.jpg`} | ||
alt={title} | ||
effect='blur' | ||
onClick={() => setIsPlayerVisible(true)} | ||
/> | ||
<div | ||
className='video-overlay' | ||
onClick={() => setIsPlayerVisible(true)} | ||
> | ||
<div className='play-button'> | ||
<div className='play-button-triangle' /> | ||
</div> | ||
</div> | ||
</> | ||
) : ( | ||
<ReactPlayer | ||
className='workshop-video' | ||
id={'id_' + title.replace(/ /g, '_')} | ||
controls={true} | ||
width='100%' | ||
url={youtube} | ||
/> | ||
)} | ||
</div> | ||
|
||
<hgroup className='workshop-header'> | ||
<h3 className='workshop-title'>{title}</h3> | ||
<h4 className='workshop-author'>Taught by: {author}</h4> | ||
</hgroup> | ||
<p className='workshop-description'>{description}</p> | ||
<div className='workshop-links'> | ||
<button className='workshop-button'> | ||
<Youtube color='var(--hackAccent)' size={28} /> | ||
<a className='workshop-link' href={youtube} target='_blank' rel='noreferrer'> Video</a> | ||
</button> | ||
{README} | ||
{SLIDES} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.