UNPKG

react-bootstrap

Version:

Bootstrap 3 components build with React

54 lines (45 loc) 1.18 kB
"use strict"; /** @jsx React.DOM */ var React = require("./react-es6")["default"]; var classSet = require("./react-es6/lib/cx")["default"]; var BootstrapMixin = require("./BootstrapMixin")["default"]; var NavItem = React.createClass({displayName: 'NavItem', mixins: [BootstrapMixin], propTypes: { onSelect: React.PropTypes.func, isActive: 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.isActive, 'disabled': this.props.disabled }; return this.transferPropsTo( React.DOM.li( {className:classSet(classes)}, React.DOM.a( {href:this.props.href, title:this.props.title, onClick:this.handleClick}, this.props.children ) ) ); }, handleClick: function (e) { if (this.props.onSelect) { e.preventDefault(); if (!this.props.disabled) { this.props.onSelect(this.props.key); } } } }); exports["default"] = NavItem;