Merge pull request #34 from rschamp/bugfix/navigation-quirks

Fix navigation quirks
This commit is contained in:
Ray Schamp 2015-10-08 10:46:49 -06:00
commit d457897971

View file

@ -26,9 +26,17 @@ module.exports = React.createClass({
'accountNavOpen': false 'accountNavOpen': false
}; };
}, },
componentDidUpdate: function (prevProps, prevState) {
if (prevState.session.user != this.state.session.user) {
this.setState({
'loginOpen': false,
'accountNavOpen': false
});
}
},
handleLoginClick: function (e) { handleLoginClick: function (e) {
e.preventDefault(); e.preventDefault();
this.setState({'loginOpen': true}); this.setState({'loginOpen': !this.state.loginOpen});
}, },
closeLogin: function () { closeLogin: function () {
this.setState({'loginOpen': false}); this.setState({'loginOpen': false});
@ -53,7 +61,8 @@ module.exports = React.createClass({
} }
}.bind(this)); }.bind(this));
}, },
handleLogOut: function () { handleLogOut: function (e) {
e.preventDefault();
xhr({ xhr({
host: '', host: '',
uri: '/accounts/logout/' uri: '/accounts/logout/'
@ -66,7 +75,8 @@ module.exports = React.createClass({
} }
}.bind(this)); }.bind(this));
}, },
handleClickAccountNav: function () { handleAccountNavClick: function (e) {
e.preventDefault();
this.setState({'accountNavOpen': true}); this.setState({'accountNavOpen': true});
}, },
closeAccountNav: function () { closeAccountNav: function () {
@ -83,7 +93,7 @@ module.exports = React.createClass({
<li className="logo"><a href="/"></a></li> <li className="logo"><a href="/"></a></li>
<li className="link"><a href="/projects/editor">Create</a></li> <li className="link"><a href="/projects/editor">Create</a></li>
<li className="link"><a href="/explore">Explore</a></li> <li className="link"><a href="/explore?date=this_month">Explore</a></li>
<li className="link"><a href="/discuss">Discuss</a></li> <li className="link"><a href="/discuss">Discuss</a></li>
<li className="link"><a href="/about">About</a></li> <li className="link"><a href="/about">About</a></li>
<li className="link"><a href="/help">Help</a></li> <li className="link"><a href="/help">Help</a></li>
@ -104,7 +114,7 @@ module.exports = React.createClass({
<a href="/mystuff/" title="My Stuff">My Stuff</a> <a href="/mystuff/" title="My Stuff">My Stuff</a>
</li>, </li>,
<li className="link right account-nav" key="account-nav"> <li className="link right account-nav" key="account-nav">
<a className="userInfo" href="#" onClick={this.handleClickAccountNav}> <a className="userInfo" href="#" onClick={this.handleAccountNavClick}>
<Avatar src={this.state.session.user.thumbnailUrl} /> <Avatar src={this.state.session.user.thumbnailUrl} />
{this.state.session.user.username} {this.state.session.user.username}
</a> </a>
@ -123,7 +133,10 @@ module.exports = React.createClass({
] : [ ] : [
<li className="link right join" key="join"><a href="/join">Join Scratch</a></li>, <li className="link right join" key="join"><a href="/join">Join Scratch</a></li>,
<li className="link right" key="login"> <li className="link right" key="login">
<a href="#" onClick={this.handleLoginClick}>Sign In</a> <a
href="#"
onClick={this.handleLoginClick}
className="ignore-react-onclickoutside">Sign In</a>
<Dropdown <Dropdown
className="login-dropdown with-arrow" className="login-dropdown with-arrow"
isOpen={this.state.loginOpen} isOpen={this.state.loginOpen}