2015-06-29 09:50:25 -07:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
2015-06-04 10:53:01 -07:00
|
|
|
|
2015-06-29 09:50:25 -07:00
|
|
|
export default class extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
}
|
2015-06-04 10:53:01 -07:00
|
|
|
|
2015-06-29 09:50:25 -07:00
|
|
|
static displayName = 'NavItem'
|
|
|
|
static propTypes = {
|
2015-06-04 10:53:01 -07:00
|
|
|
onSelect: React.PropTypes.func,
|
|
|
|
active: React.PropTypes.bool,
|
|
|
|
disabled: React.PropTypes.bool,
|
|
|
|
href: React.PropTypes.string,
|
|
|
|
title: React.PropTypes.string,
|
|
|
|
eventKey: React.PropTypes.any,
|
|
|
|
target: React.PropTypes.string
|
2015-06-29 09:50:25 -07:00
|
|
|
}
|
2015-06-04 10:53:01 -07:00
|
|
|
|
2015-06-29 09:50:25 -07:00
|
|
|
handleClick(e) {
|
|
|
|
if (this.props.onSelect) {
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (!this.props.disabled) {
|
|
|
|
this.props.onSelect(
|
|
|
|
this.props.eventKey,
|
|
|
|
this.props.href,
|
|
|
|
this.props.target
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-04 10:53:01 -07:00
|
|
|
|
2015-06-29 09:50:25 -07:00
|
|
|
render() {
|
|
|
|
const {
|
|
|
|
disabled,
|
|
|
|
active,
|
|
|
|
href,
|
|
|
|
title,
|
|
|
|
target,
|
|
|
|
children,
|
|
|
|
} = this.props;
|
|
|
|
|
|
|
|
const classes = {
|
|
|
|
'active': active,
|
|
|
|
'disabled': disabled
|
|
|
|
};
|
2015-06-04 10:53:01 -07:00
|
|
|
|
|
|
|
return (
|
2015-06-29 09:50:25 -07:00
|
|
|
<li
|
|
|
|
className={ joinClasses(props.className, classSet(classes)) }
|
|
|
|
{ ...this.props }>
|
2015-06-04 10:53:01 -07:00
|
|
|
<a
|
|
|
|
href={href}
|
|
|
|
title={title}
|
|
|
|
target={target}
|
|
|
|
className={ this.props.aClassName }
|
|
|
|
onClick={this.handleClick}
|
|
|
|
ref="anchor">
|
|
|
|
{ children }
|
|
|
|
</a>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
}
|
2015-06-29 09:50:25 -07:00
|
|
|
}
|