diff --git a/src/components/App/App.jsx b/src/components/App/App.jsx index a03d23f..f71ae6a 100644 --- a/src/components/App/App.jsx +++ b/src/components/App/App.jsx @@ -1,54 +1,52 @@ import React, { Component } from 'react'; import AuthService from '../../utils/AuthService' import './App.scss'; -import MainMenu from '../MainMenu/MainMenu'; -import Login from '../Login/Login'; +import Navbar from '../Navbar/Navbar'; -const options = { - auth: { - params: { - redirectUrl: 'http://localhost:8080', - responseType: 'token' - } - } -}; +const options = {}; const auth = new AuthService(__AUTH0_CLIENT_ID__, __AUTH0_DOMAIN__, options); class App extends Component { constructor(props) { super(props); this.state = { - profile: auth.getProfile() + isAuthenticated: this.isAuthenticated(), + /*profile: auth.getProfile()*/ } auth.on('profile_updated', (newProfile) => { - this.setState({profile: newProfile}) + // do i need a check for valid profile? + this.setState({isAuthenticated: this.isAuthenticated(), /*profile: newProfile*/}); }) - this.loginButton = this.loginButton.bind(this); + this.logout = this.logout.bind(this); + this.getNickName = this.getNickName.bind(this); + } + + isAuthenticated() { + return auth.getProfile() && auth.getProfile().hasOwnProperty('user_id'); + } + + getNickName() { + return auth.getProfile() && auth.getProfile().hasOwnProperty('nickname')?auth.getProfile().nickname:''; } logout() { - auth.logout() - this.setState({ - profile: auth.getProfile() - }) - } - - loginButton() { - if(this.state.profile.hasOwnProperty('user_id')) - return ; - else - return ; + auth.logout(); + this.setState({isAuthenticated: this.isAuthenticated()}); } render() { + let loginButton = !this.state.isAuthenticated ? + : ''; + return (
- - {this.loginButton()} + +
+
{loginButton}
+
) } } -// export default App; \ No newline at end of file diff --git a/src/components/App/App.scss b/src/components/App/App.scss index a065286..20b35af 100644 --- a/src/components/App/App.scss +++ b/src/components/App/App.scss @@ -4,15 +4,21 @@ html { } body { min-height: 100%; - font-family: 'Gill Sans', 'Gill Sans MT', Calibri, 'Trebuchet MS', sans-serif; - background-color: #eee; + font-family: "Trebuchet MS","Lucida Grande","Lucida Sans Unicode","Lucida Sans",Tahoma,sans-serif; + background-color: #f5f5f5; color: #111; } .container { margin: 0 auto; - padding: 20px 0 20px; max-width: 1024px; } .row { margin: 0; +} +.login-button { + font-size: 2.0rem; + padding: 6px 15px; +} +.game { + padding-top: 80px; } \ No newline at end of file diff --git a/src/components/Login/Login.jsx b/src/components/Login/Login.jsx deleted file mode 100644 index 2230114..0000000 --- a/src/components/Login/Login.jsx +++ /dev/null @@ -1,36 +0,0 @@ -import React, { Component, PropTypes as T } from 'react'; -import AuthService from '../../utils/AuthService' -import './Login.scss'; - -class Login extends Component { - constructor(props) { - super(props); - this.loginButton = this.loginButton.bind(this); - } - - logout() { -/* this.props.auth.logout() - this.setState({ - profile: this.props.auth.getProfile() - }) */ - } - - loginButton() { - if(this.props.profile.hasOwnProperty('user_id')) - return ; - else - return ; - } - - render() { - return ( -
{this.loginButton()}
- ) - } -} - -Login.propTypes = { - auth: T.instanceOf(AuthService) -}; - -export default Login; \ No newline at end of file diff --git a/src/components/Login/Login.scss b/src/components/Login/Login.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/MainMenu/MainMenu.jsx b/src/components/MainMenu/MainMenu.jsx deleted file mode 100644 index a8b6402..0000000 --- a/src/components/MainMenu/MainMenu.jsx +++ /dev/null @@ -1,12 +0,0 @@ -import React, { Component } from 'react'; -import './MainMenu.scss'; - -class MainMenu extends Component { - render() { - return ( -
{this.props.profile.hasOwnProperty('user_id')?this.props.profile.name+' is logged in':'not logged in'}
- ) - } -} - -export default MainMenu; \ No newline at end of file diff --git a/src/components/MainMenu/MainMenu.scss b/src/components/MainMenu/MainMenu.scss deleted file mode 100644 index e69de29..0000000 diff --git a/src/components/Navbar/Navbar.jsx b/src/components/Navbar/Navbar.jsx new file mode 100644 index 0000000..9fc69e5 --- /dev/null +++ b/src/components/Navbar/Navbar.jsx @@ -0,0 +1,31 @@ +import React, { Component } from 'react'; +import './Navbar.scss'; + +class Navbar extends Component { + render() { + let profileButton = this.props.isAuthenticated ? + {this.props.nickName} : + Log in; + return ( + + ) + } +} +//
{this.props.profile.hasOwnProperty('user_id')?this.props.profile.name+' is logged in':'not logged in'}
+ // + +export default Navbar; \ No newline at end of file diff --git a/src/components/Navbar/Navbar.scss b/src/components/Navbar/Navbar.scss new file mode 100644 index 0000000..8688ebe --- /dev/null +++ b/src/components/Navbar/Navbar.scss @@ -0,0 +1,90 @@ +#nav-profile { + text-transform:capitalize; +} +#navbar ul li { + font-size: 1.2em; + .glyphicon { + font-size: 0.9em; + color: #62bbff; + } +} +.navbar-inverse { + background-color: #333; +} +// From http://getbootstrap.com/examples/non-responsive/non-responsive.css +.container .navbar-header, +.container .navbar-collapse { + margin-right: 0; + margin-left: 0; +} + +/* Always float the navbar header */ +.navbar-header { + float: left; +} + +/* Undo the collapsing navbar */ +.navbar-collapse { + display: block !important; + height: auto !important; + padding-bottom: 0; + overflow: visible !important; +} + +.navbar-toggle { + display: none; +} +.navbar-collapse { + border-top: 0; +} + +.navbar-brand { + margin-left: -15px; +} + +/* Always apply the floated nav */ +.navbar-nav { + float: left; + margin: 0; +} +.navbar-nav > li { + float: left; +} +.navbar-nav > li > a { + padding: 15px; +} + +/* Redeclare since we override the float above */ +.navbar-nav.navbar-right { + float: right; +} + +/* Undo custom dropdowns */ +.navbar .navbar-nav .open .dropdown-menu { + position: absolute; + float: left; + background-color: #fff; + border: 1px solid #ccc; + border: 1px solid rgba(0, 0, 0, .15); + border-width: 0 1px 1px; + border-radius: 0 0 4px 4px; + -webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, .175); + box-shadow: 0 6px 12px rgba(0, 0, 0, .175); +} +.navbar-default .navbar-nav .open .dropdown-menu > li > a { + color: #333; +} +.navbar .navbar-nav .open .dropdown-menu > li > a:hover, +.navbar .navbar-nav .open .dropdown-menu > li > a:focus, +.navbar .navbar-nav .open .dropdown-menu > .active > a, +.navbar .navbar-nav .open .dropdown-menu > .active > a:hover, +.navbar .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #fff !important; + background-color: #428bca !important; +} +.navbar .navbar-nav .open .dropdown-menu > .disabled > a, +.navbar .navbar-nav .open .dropdown-menu > .disabled > a:hover, +.navbar .navbar-nav .open .dropdown-menu > .disabled > a:focus { + color: #999 !important; + background-color: transparent !important; +} \ No newline at end of file diff --git a/src/index.html b/src/index.html index 1ae0411..45c837a 100644 --- a/src/index.html +++ b/src/index.html @@ -9,6 +9,6 @@ -
+
\ No newline at end of file diff --git a/src/index.js b/src/index.js index 988353e..4b73c05 100644 --- a/src/index.js +++ b/src/index.js @@ -4,4 +4,4 @@ import Bootstrap from './assets/stylesheets/bootstrap.min.css'; import App from './components/App/App'; let element = React.createElement(App, {}); -render(element, document.querySelector('.container')); \ No newline at end of file +render(element, document.querySelector('.app')); \ No newline at end of file