Last active
March 23, 2020 15:17
-
-
Save mfbx9da4/fbc6a8c367b83d7330562c0fd10ae06b to your computer and use it in GitHub Desktop.
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
import { Component } from 'react' | |
class OverlayDesign extends Component { | |
state = { | |
hide: true, | |
} | |
listener = event => { | |
if (event.keyCode === 74) { | |
this.setState({ hide: !this.state.hide }) | |
} | |
} | |
componentDidMount() { | |
window.addEventListener('keydown', this.listener) | |
} | |
componentWillUnmount() { | |
window.removeEventListener('keydown', this.listener) | |
} | |
render() { | |
return ( | |
<div | |
style={{ | |
position: 'absolute', | |
top: 0, | |
left: 0, | |
right: 0, | |
zIndex: 99999999, | |
display: this.state.hide ? 'none' : 'block', | |
objectFit: 'cover', | |
}} | |
> | |
<img | |
style={{ width: '100%' }} | |
src={this.props.src} | |
alt={this.props.src} | |
/> | |
</div> | |
) | |
} | |
} | |
export default OverlayDesign |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment