Skip to content

Instantly share code, notes, and snippets.

@stirtingale
Created July 23, 2020 12:04
Show Gist options
  • Save stirtingale/35003e0d877a50dae41f85861254300d to your computer and use it in GitHub Desktop.
Save stirtingale/35003e0d877a50dae41f85861254300d to your computer and use it in GitHub Desktop.
React Component Based on 'Tasty CSS-animated hamburgers' @ https://jonsuh.com/hamburgers/
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