Created
July 23, 2020 12:04
-
-
Save stirtingale/35003e0d877a50dae41f85861254300d to your computer and use it in GitHub Desktop.
React Component Based on 'Tasty CSS-animated hamburgers' @ https://jonsuh.com/hamburgers/
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
class Burger extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {addClass: false} | |
} | |
toggle() { | |
this.setState({addClass: !this.state.addClass}); | |
} | |
render() { | |
let burderClass = ["hamburger hamburger--collapse"]; | |
if(this.state.addClass) { | |
burderClass.push('is-active'); | |
} | |
return( | |
<button className={burderClass.join(' ')} onClick={this.toggle.bind(this)} type="button"><span class="hamburger-box"><span class="hamburger-inner"></span></span></button> | |
); | |
} | |
} | |
ReactDOM.render(<Burger />, document.getElementById("root")); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment