Skip to content

Instantly share code, notes, and snippets.

@sethlivingston
Created November 26, 2015 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethlivingston/944d1b99785b90f5b525 to your computer and use it in GitHub Desktop.
Save sethlivingston/944d1b99785b90f5b525 to your computer and use it in GitHub Desktop.
var classnames = require('classnames');
var {Link, History} = require('react-router');
var React = require('react');
var NavPanelButton = React.createClass({
mixins: [History],
click: function (e) {
e.preventDefault();
this.history.pushState(null, this.props.link);
},
render: function () {
var buttonClasses = classnames({
'nav-panel-button': true,
'selected': this.history.isActive(this.props.link)
});
var iconClasses = `fa fa-${this.props.icon} fa-fw`;
return (
<div className={buttonClasses} onClick={this.click}>
<Link to={this.props.link}>
<i className={iconClasses}/> {this.props.children}
</Link>
</div>
);
}
});
module.exports = NavPanelButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment