-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Component: VideoOnClick #3
base: master
Are you sure you want to change the base?
Changes from 8 commits
4a58a38
d2c15c1
30dc34a
b657f65
793abc2
acf67f9
15b9bad
a1c851f
9b59f9b
4373912
9cca402
cadccba
dd54901
4fc57ce
658308c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
declare module 'video-react'; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import * as React from 'react' | ||
import { Player, BigPlayButton, ControlBar } from 'video-react' | ||
import { css } from 'react-emotion' | ||
import IconButton from '@material-ui/core/IconButton' | ||
import Pause from '@material-ui/icons/Pause' | ||
import PlayArrow from '@material-ui/icons/PlayArrow' | ||
import VolumeUp from '@material-ui/icons/VolumeUp' | ||
import VolumeOff from '@material-ui/icons/VolumeOff' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we already use font awesome icons for most things, any chance we could use font awesome icons for these? |
||
|
||
import 'video-react/dist/video-react.css' | ||
|
||
interface VideoOnClickState { | ||
video: boolean | ||
mute: boolean | ||
} | ||
|
||
interface VideoOnClickProps { | ||
videoURL: string | ||
imageURL: string | ||
} | ||
|
||
class VideoOnClick extends React.Component< | ||
VideoOnClickProps, | ||
VideoOnClickState | ||
> { | ||
state = { | ||
video: false, | ||
mute: false, | ||
} | ||
|
||
toggleMuted = () => { | ||
this.setState(prevState => ({ mute: !prevState.mute })) | ||
} | ||
|
||
toggle = () => { | ||
this.setState(prevState => ({ video: !prevState.video })) | ||
} | ||
|
||
render() { | ||
console.log(this.props) | ||
return ( | ||
<div | ||
className={css` | ||
height: 300px; | ||
width: 400px; | ||
`} | ||
> | ||
{this.state.video && ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since we're rendering components when we both have video and not, let's use a ternary |
||
<div | ||
className={css` | ||
position: relative; | ||
`} | ||
> | ||
<div | ||
className={css` | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
z-index: 100; | ||
color: white; | ||
`} | ||
> | ||
<IconButton onClick={this.toggle}> | ||
<Pause | ||
fontSize="small" | ||
className={css` | ||
color: white; | ||
`} | ||
/> | ||
</IconButton> | ||
</div> | ||
<div | ||
onClick={this.toggleMuted} | ||
className={css` | ||
position: absolute; | ||
bottom: 0; | ||
right: 0; | ||
z-index: 100; | ||
color: white; | ||
`} | ||
> | ||
<IconButton> | ||
{this.state.mute ? ( | ||
<VolumeOff | ||
fontSize="small" | ||
className={css` | ||
color: white; | ||
`} | ||
/> | ||
) : ( | ||
<VolumeUp | ||
fontSize="small" | ||
className={css` | ||
color: white; | ||
`} | ||
/> | ||
)} | ||
</IconButton> | ||
</div> | ||
<Player | ||
playsInline | ||
autoPlay | ||
poster="/assets/poster.png" | ||
muted={this.state.mute} | ||
src={this.props.videoURL} | ||
> | ||
<BigPlayButton position="center" /> | ||
<ControlBar disableCompletely className="my-class" /> | ||
</Player> | ||
</div> | ||
)} | ||
{!this.state.video && ( | ||
<div | ||
className={css` | ||
position: relative; | ||
filter: none; | ||
-webkit-filter: grayscale(100%); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need vendor prefixes, emotion handles that automatically |
||
-moz-filter: grayscale(100%); | ||
-ms-filter: grayscale(100%); | ||
-o-filter: grayscale(100%); | ||
transition: 0.2s; | ||
&:hover { | ||
filter: none; | ||
-webkit-filter: grayscale(0%); | ||
-moz-filter: grayscale(0%); | ||
-ms-filter: grayscale(0%); | ||
-o-filter: grayscale(0%); | ||
cursor: pointer; | ||
} | ||
`} | ||
> | ||
<div | ||
className={css` | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
z-index: 100; | ||
color: white; | ||
`} | ||
> | ||
<IconButton onClick={this.toggle}> | ||
<PlayArrow | ||
fontSize="small" | ||
className={css` | ||
color: white; | ||
`} | ||
/> | ||
</IconButton> | ||
</div> | ||
<img src={this.props.imageURL} className={css``} /> | ||
legitmaxwu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</div> | ||
)} | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
export default VideoOnClick |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a newline https://stackoverflow.com/questions/729692/why-should-text-files-end-with-a-newline