Fixing logout button
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"expoServerPort": null,
|
"expoServerPort": 19000,
|
||||||
"packagerPort": null,
|
"packagerPort": 19001,
|
||||||
"packagerPid": null
|
"packagerPid": 46572
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
"description": "Deighton AR Server",
|
"description": "Deighton AR Server",
|
||||||
"main": "src/server.js",
|
"main": "src/server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "babel-node src/dar-server.js",
|
"start": "babel-node src/server.js",
|
||||||
"start:prod": "NODE_ENV=production npm start",
|
"start:prod": "NODE_ENV=production npm start",
|
||||||
"build": "babel src -d dist -s",
|
"build": "babel src -d dist -s",
|
||||||
"serve": "NODE_ENV=production node dist/server.js",
|
"serve": "NODE_ENV=production node dist/server.js",
|
||||||
|
|||||||
@@ -9,10 +9,38 @@ import logoImage from 'images/logo.png'
|
|||||||
import { versionInfo } from './version'
|
import { versionInfo } from './version'
|
||||||
import { sizeInfo } from 'ui/style'
|
import { sizeInfo } from 'ui/style'
|
||||||
import { api } from 'src/API'
|
import { api } from 'src/API'
|
||||||
|
import { reactAutoBind } from 'auto-bind2'
|
||||||
|
|
||||||
export class App extends React.Component {
|
export class App extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
this.state = {
|
||||||
|
loggedInUser: api.loggedInUser
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
handleUpdate() {
|
||||||
|
this.setState({ loggedInUser: api.loggedInUser })
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
api.addListener('login', this.handleUpdate)
|
||||||
|
api.addListener('logout', this.handleUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
api.removeListener('login', this.handleUpdate)
|
||||||
|
api.removeListener('logout', this.handleUpdate)
|
||||||
|
}
|
||||||
|
|
||||||
|
handleLogout() {
|
||||||
|
api.logout()
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const height = sizeInfo.headerHeight - sizeInfo.headerBorderWidth
|
const height = sizeInfo.headerHeight - sizeInfo.headerBorderWidth
|
||||||
|
const { loggedInUser } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column minHeight='100vh'>
|
<Column minHeight='100vh'>
|
||||||
@@ -24,10 +52,10 @@ export class App extends React.Component {
|
|||||||
height={height}
|
height={height}
|
||||||
margin={sizeInfo.headerMargin} />
|
margin={sizeInfo.headerMargin} />
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item grow> </Row.Item>
|
<Row.Item grow />
|
||||||
<Row.Item>
|
<Row.Item>
|
||||||
{ api.loggedInUser && <HeaderButton icon='profile' size={height} /> }
|
{ loggedInUser && <HeaderButton icon='profile' size={height} /> }
|
||||||
{ api.loggedInUser && <HeaderButton icon='logout' size={height} /> }
|
{ loggedInUser && <HeaderButton icon='logout' size={height} onClick={this.handleLogout} /> }
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
</Row>
|
</Row>
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ export default {
|
|||||||
borderWidth: 0,
|
borderWidth: 0,
|
||||||
padding: '0 0 0 0',
|
padding: '0 0 0 0',
|
||||||
outline: 'none',
|
outline: 'none',
|
||||||
|
|
||||||
':hover': {
|
':hover': {
|
||||||
background: colorInfo.headerButtonBackgroundHover,
|
background: colorInfo.headerButtonBackgroundHover,
|
||||||
|
},
|
||||||
|
':active': {
|
||||||
|
background: colorInfo.headerButtonBackgroundActive,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ export const colorInfo = {
|
|||||||
buttonBackgroundHover: '#3CB0FD',
|
buttonBackgroundHover: '#3CB0FD',
|
||||||
headerButtonBackground: '#FAFAFA',
|
headerButtonBackground: '#FAFAFA',
|
||||||
headerButtonBackgroundHover: '#DADADA',
|
headerButtonBackgroundHover: '#DADADA',
|
||||||
|
headerButtonBackgroundActive: '#AAAAAA',
|
||||||
disabledButtonBackground: '#E0E0E0',
|
disabledButtonBackground: '#E0E0E0',
|
||||||
modalBackground: '#FFFFFF',
|
modalBackground: '#FFFFFF',
|
||||||
uncheckedCheckbox: '#A0A0A0',
|
uncheckedCheckbox: '#A0A0A0',
|
||||||
|
|||||||
Reference in New Issue
Block a user