fix use special navItem for signin button

This commit is contained in:
Berkeley Martinez
2015-07-03 19:34:20 -07:00
parent 6ad1a0af23
commit 9825f55754
2 changed files with 55 additions and 33 deletions

View File

@ -1,5 +1,6 @@
import React from 'react'; import React from 'react';
import { Nav, Navbar, NavItem } from 'react-bootstrap'; import { Nav, Navbar, NavItem } from 'react-bootstrap';
import FCCNavItem from './NavItem.jsx';
export default class extends React.Component { export default class extends React.Component {
constructor(props) { constructor(props) {
@ -33,12 +34,12 @@ export default class extends React.Component {
); );
} else { } else {
return ( return (
<NavItem <FCCNavItem
className='btn signup-btn signup-btn-nav' className='btn signup-btn signup-btn-nav'
eventKey={ 2 } eventKey={ 2 }
href='/login'> href='/login'>
Sign In Sign In
</NavItem> </FCCNavItem>
); );
} }
} }

View File

@ -1,65 +1,86 @@
import React from 'react'; import React from 'react';
import classnames from 'classnames'; import classNames from 'classnames';
import BootstrapMixin from 'react-bootstrap/lib/BootstrapMixin';
export default class extends React.Component { export default React.createClass({
constructor(props) { displayName: 'FCCNavItem',
super(props); mixins: [BootstrapMixin],
}
static displayName = 'NavItem' propTypes: {
static propTypes = {
onSelect: React.PropTypes.func,
active: React.PropTypes.bool, active: React.PropTypes.bool,
'aria-controls': React.PropTypes.string,
disabled: React.PropTypes.bool, disabled: React.PropTypes.bool,
href: React.PropTypes.string,
title: React.PropTypes.string,
eventKey: React.PropTypes.any, eventKey: React.PropTypes.any,
target: React.PropTypes.string href: React.PropTypes.string,
} linkId: React.PropTypes.string,
onSelect: React.PropTypes.func,
role: React.PropTypes.string,
target: React.PropTypes.string,
title: React.PropTypes.node
},
getDefaultProps() {
return {
href: '#'
};
},
handleClick(e) { handleClick(e) {
if (this.props.onSelect) { if (this.props.onSelect) {
e.preventDefault(); e.preventDefault();
if (!this.props.disabled) { if (!this.props.disabled) {
this.props.onSelect( this.props.onSelect(this.props.eventKey, this.props.href, this.props.target);
this.props.eventKey,
this.props.href,
this.props.target
);
} }
} }
} },
render() { render() {
const { let {
role,
linkId,
disabled, disabled,
active, active,
href, href,
title, title,
target, target,
children, children,
'aria-controls': ariaControls, // eslint-disable-line react/prop-types
className,
...props
} = this.props; } = this.props;
const classes = { let classes = {
'active': active, active,
'disabled': disabled disabled
}; };
let linkProps = {
role,
href,
title,
target,
id: linkId,
onClick: this.handleClick,
ref: 'anchor'
};
if (!role && href === '#') {
linkProps.role = 'button';
}
return ( return (
<li <li
className={ joinClasses(props.className, classSet(classes)) } {...props}
{ ...this.props }> role='presentation'>
<a <a
href={href} { ...linkProps }
title={title} aria-selected={ active }
target={target} aria-controls={ ariaControls }
className={ this.props.aClassName } className={ className }>
onClick={this.handleClick}
ref="anchor">
{ children } { children }
</a> </a>
</li> </li>
); );
} }
} });