diff --git a/src/components/AuthMenu.js b/src/components/AuthMenu.js new file mode 100644 index 0000000..7fc4e94 --- /dev/null +++ b/src/components/AuthMenu.js @@ -0,0 +1,80 @@ +import React, { Component } from 'react'; + +class AuthMenu extends Component { + constructor (props) { + super(props) + + this.state = { + where_in_auth_menu: "username", + } + + this.handleSignUpRequest = this.handleSignUpRequest.bind(this) + this.handleLogInAttempt = this.handleLogInAttempt.bind(this) + this.handleAccountCreation = this.handleAccountCreation.bind(this) + this.authMenu = this.authMenu.bind(this) + + } + + handleSignUpRequest() { + this.setState(state => ({ + where_in_auth_menu: "email", + auth_menu_visible: true, + })); + } + + handleLogInAttempt() { + this.setState(state => ({ + where_in_auth_menu: "password", + auth_menu_visible: true, + })); + } + handleAccountCreation() { + this.setState(state => ({ + where_in_auth_menu: "password", + auth_menu_visible: true, + })); + } + + authMenu() { + if (!this.props.auth_menu_visible) { + return null; + } + switch(this.state.where_in_auth_menu) { + case 'username': + return ( +
+
+ + + +
+
+ +
+ +
+
+ ) + case 'password': + return ( +
+
+ + + +
+
+ ) + default: + return null; + } + } + + render() { + return ( + this.authMenu(this.state.auth_menu_visible) + ) + } +} + +export default (AuthMenu) diff --git a/src/components/NavBar.js b/src/components/NavBar.js index 8916883..80f4742 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -1,32 +1,7 @@ import React, { Component } from 'react'; import { NavLink } from 'react-router-dom'; import { connect } from 'react-redux'; - -function AuthMenu(props) { - if (!props.showMenu) { - return null; - } - - return ( -
-
- - - -
-
- - - -
-
- -
- -
-
- ) -} +import AuthMenu from './AuthMenu'; class NavBar extends Component { constructor (props) { @@ -34,14 +9,13 @@ class NavBar extends Component { this.state = { logged_in: false, auth_menu_visible: false, - where_in_auth_menu: false, } this.handleLoginDropdown = this.handleLoginDropdown.bind(this) } handleLoginDropdown() { this.setState(state => ({ - auth_menu_visible: !state.auth_menu_visible + auth_menu_visible: true })); } @@ -55,7 +29,7 @@ class NavBar extends Component {
Login - +