forked from react-bootstrap/react-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNavItem.jsx
54 lines (45 loc) · 1.11 KB
/
NavItem.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/** @jsx React.DOM */
import React from './react-es6';
import classSet from './react-es6/lib/cx';
import BootstrapMixin from './BootstrapMixin';
var NavItem = React.createClass({
mixins: [BootstrapMixin],
propTypes: {
onSelect: React.PropTypes.func,
active: React.PropTypes.bool,
disabled: React.PropTypes.bool,
href: React.PropTypes.string,
title: React.PropTypes.string
},
getDefaultProps: function () {
return {
href: '#'
};
},
render: function () {
var classes = {
'active': this.props.active,
'disabled': this.props.disabled
};
return this.transferPropsTo(
<li className={classSet(classes)}>
<a
href={this.props.href}
title={this.props.title}
onClick={this.handleClick}
ref="anchor">
{this.props.children}
</a>
</li>
);
},
handleClick: function (e) {
if (this.props.onSelect) {
e.preventDefault();
if (!this.props.disabled) {
this.props.onSelect(this.props.key,this.props.href);
}
}
}
});
export default = NavItem;