Skip to content

Commit 101892a

Browse files
committed
chore: lint client
1 parent fe19357 commit 101892a

20 files changed

Lines changed: 400 additions & 417 deletions

client/components/App.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import BoardContainer from '../containers/BoardContainer'
66
import BackgroundtrackContainer from '../containers/BackgroundtrackContainer'
77

88
class App extends Component {
9-
109
render () {
1110
return (
1211
<div className='app'>
Lines changed: 43 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,86 @@
1-
import React, { Component }from 'react';
2-
import Sound from 'react-sound';
1+
import React, { Component } from 'react'
2+
import Sound from 'react-sound'
33
import cookie from 'react-cookie'
4-
import songs from '../sound';
4+
import songs from '../sound'
55

66
export default class Backgroundtrack extends Component {
7-
8-
constructor(props) {
9-
super(props);
7+
constructor (props) {
8+
super(props)
109

1110
this.state = {
12-
theme : 0,
11+
theme: 0,
1312
currentSong: songs[0],
1413
position: 0,
1514
volume: 25,
1615
playStatus: Sound.status.STOPPED
17-
};
16+
}
1817
}
1918

20-
getStatusText() {
21-
switch(this.state.playStatus) {
19+
getStatusText () {
20+
switch (this.state.playStatus) {
2221
case Sound.status.PLAYING:
23-
return 'playing';
22+
return 'playing'
2423
case Sound.status.PAUSED:
25-
return 'paused';
24+
return 'paused'
2625
case Sound.status.STOPPED:
27-
return 'stopped';
26+
return 'stopped'
2827
default:
29-
return '(unknown)';
28+
return '(unknown)'
3029
}
3130
}
3231

3332
componentDidMount () {
3433
const cookies = cookie.load('sound')
3534
if (cookies === undefined) {
36-
cookie.save('sound', 'ON');
37-
this.setState({playStatus: Sound.status.PLAYING});
38-
}
39-
else if(cookies === 'ON'){
40-
this.setState({playStatus: Sound.status.PLAYING});
41-
}
42-
else {
43-
this.setState({playStatus: Sound.status.STOPPED});
35+
cookie.save('sound', 'ON')
36+
this.setState({ playStatus: Sound.status.PLAYING })
37+
} else if (cookies === 'ON') {
38+
this.setState({ playStatus: Sound.status.PLAYING })
39+
} else {
40+
this.setState({ playStatus: Sound.status.STOPPED })
4441
}
4542
}
4643

47-
componentDidUpdate(){
48-
var newTheme = 0
49-
if (this.props.currentLevel >=1 && this.props.currentLevel < 6 ) {
50-
newTheme = 0;
51-
}
52-
else if (this.props.currentLevel >=6 && this.props.currentLevel < 11) {
53-
newTheme = 1;
54-
}
55-
else if (this.props.currentLevel >=11 && this.props.currentLevel < 16) {
56-
newTheme = 2;
57-
}
58-
else if (this.props.currentLevel >=16 && this.props.currentLevel < 21) {
59-
newTheme = 3;
60-
}
61-
else {
62-
newTheme = 4;
44+
componentDidUpdate () {
45+
let newTheme = 0
46+
if (this.props.currentLevel >= 1 && this.props.currentLevel < 6) {
47+
newTheme = 0
48+
} else if (this.props.currentLevel >= 6 && this.props.currentLevel < 11) {
49+
newTheme = 1
50+
} else if (this.props.currentLevel >= 11 && this.props.currentLevel < 16) {
51+
newTheme = 2
52+
} else if (this.props.currentLevel >= 16 && this.props.currentLevel < 21) {
53+
newTheme = 3
54+
} else {
55+
newTheme = 4
6356
}
6457

65-
if(this.state.theme !== newTheme){
66-
this.setState({theme: newTheme, currentSong: songs[newTheme]})
58+
if (this.state.theme !== newTheme) {
59+
this.setState({ theme: newTheme, currentSong: songs[newTheme] })
6760
}
6861

6962
const cookies = cookie.load('sound')
7063
const isAlreadySet = this.state.playStatus === Sound.status.PLAYING
71-
if(cookies === 'ON'){
64+
if (cookies === 'ON') {
7265
if (isAlreadySet) return
73-
this.setState({playStatus: Sound.status.PLAYING})
74-
}
75-
else {
66+
this.setState({ playStatus: Sound.status.PLAYING })
67+
} else {
7668
if (!isAlreadySet) return
77-
this.setState({playStatus: Sound.status.STOPPED})
69+
this.setState({ playStatus: Sound.status.STOPPED })
7870
}
7971
}
8072

81-
render() {
82-
return(
83-
<div>
73+
render () {
74+
return (
75+
<div>
8476
<Sound
8577
url={this.state.currentSong.url}
8678
playStatus={this.state.playStatus}
8779
playFromPosition={this.state.position}
8880
volume={this.state.volume}
89-
onFinishedPlaying={() => this.setState({playStatus: Sound.status.PLAYING})} />
90-
</div>
81+
onFinishedPlaying={() => this.setState({ playStatus: Sound.status.PLAYING })}
82+
/>
83+
</div>
9184
)
9285
}
9386
}

client/components/Board.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
import React, {Component} from 'react'
1+
import React, { Component } from 'react'
22
import RobotContainer from '../containers/RobotContainer'
33
import classNames from 'classnames'
44

55
class Board extends Component {
6-
7-
constructor(props) {
6+
constructor (props) {
87
super(props)
98
this.state = {
109
hasMounted: false
1110
}
1211
}
1312

14-
componentDidMount() {
13+
componentDidMount () {
1514
this.props.addTileInfo(this.refs)
16-
this.setState({hasMounted: true})
15+
this.setState({ hasMounted: true })
1716
}
1817

19-
render() {
20-
var levelTheme = ''
21-
var currentLevel = this.props.currentLevel
18+
render () {
19+
let levelTheme = ''
20+
const currentLevel = this.props.currentLevel
2221
if (currentLevel < 6) {
2322
levelTheme = 'basement'
2423
} else if (currentLevel < 11) {
@@ -41,29 +40,28 @@ class Board extends Component {
4140
: 'even'
4241
return (col === 3
4342
? <div key={rowIndex + colIndex} className={classNames('tile', 'clear')} ref={rowIndex.toString() + colIndex.toString()}>
44-
<img src='/resources/images/blackhole.svg' className='hole'></img>
43+
<img src='/resources/images/blackhole.svg' className='hole' />
4544
</div>
4645
: col === 2
4746
? <div key={rowIndex + colIndex} className={classNames('tile', levelTheme, oddEven)} ref={rowIndex.toString() + colIndex.toString()}>
48-
<img src='/resources/images/box-tile.svg' className='box-tile'/>
47+
<img src='/resources/images/box-tile.svg' className='box-tile' />
4948
</div>
5049
: col === 1
5150
? <div key={rowIndex + colIndex} className={classNames('tile', levelTheme, oddEven)} ref={rowIndex.toString() + colIndex.toString()}>
52-
<div className='elevator-bottom'>
53-
<img src='/resources/images/elevator-top.svg' className={ this.props.levelWon ? classNames('elevator-animation') : classNames('elevator-no-animation') }/>
54-
</div>
51+
<div className='elevator-bottom'>
52+
<img src='/resources/images/elevator-top.svg' className={this.props.levelWon ? classNames('elevator-animation') : classNames('elevator-no-animation')} />
53+
</div>
5554
</div>
56-
: <div key={rowIndex + colIndex} className={classNames('tile', levelTheme, oddEven)} ref={rowIndex.toString() + colIndex.toString()}></div>)
55+
: <div key={rowIndex + colIndex} className={classNames('tile', levelTheme, oddEven)} ref={rowIndex.toString() + colIndex.toString()} />)
5756
})
58-
})
59-
}
57+
})}
6058
</div>
6159
{this.state.hasMounted
62-
? <RobotContainer/>
60+
? <RobotContainer />
6361
: null}
6462
</div>
6563
)
6664
}
6765
}
6866

69-
export default Board
67+
export default Board

client/components/CommandPane.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import RunButtons from './RunButtons'
44
import classNames from 'classnames'
55

66
class CommandPane extends Component {
7-
87
render () {
98
return (
109
<section className='command-pane'>
@@ -16,36 +15,44 @@ class CommandPane extends Component {
1615
<div className='moves-left'><h4>Moves Left: {this.props.moveLimit - this.props.commandQueue.length}</h4></div>
1716

1817
<div className='action-button-container'>
19-
<a className={classNames(
20-
'action-button',
21-
'action-animate',
22-
{'action-forward': !this.props.running && this.props.moveLimit - this.props.commandQueue.length}
18+
<a
19+
className={classNames(
20+
'action-button',
21+
'action-animate',
22+
{ 'action-forward': !this.props.running && this.props.moveLimit - this.props.commandQueue.length }
2323
)}
24-
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('MOVE_FORWARD') }}>
24+
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('MOVE_FORWARD') }}
25+
>
2526
<img src='/resources/images/move-forward.svg' className='action-icon' />
2627
</a>
27-
<a className={classNames(
28-
'action-button',
29-
'action-animate',
30-
{'action-rotate': !this.props.running && this.props.moveLimit - this.props.commandQueue.length}
28+
<a
29+
className={classNames(
30+
'action-button',
31+
'action-animate',
32+
{ 'action-rotate': !this.props.running && this.props.moveLimit - this.props.commandQueue.length }
3133
)}
32-
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('TURN_LEFT') }}>
34+
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('TURN_LEFT') }}
35+
>
3336
<img src='/resources/images/turn-left.svg' className='action-icon' />
3437
</a>
35-
<a className={classNames(
36-
'action-button',
37-
'action-animate',
38-
{'action-rotate': !this.props.running && this.props.moveLimit - this.props.commandQueue.length}
38+
<a
39+
className={classNames(
40+
'action-button',
41+
'action-animate',
42+
{ 'action-rotate': !this.props.running && this.props.moveLimit - this.props.commandQueue.length }
3943
)}
40-
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('TURN_RIGHT') }}>
44+
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('TURN_RIGHT') }}
45+
>
4146
<img src='/resources/images/turn-right.svg' className='action-icon' />
4247
</a>
43-
<a className={classNames(
44-
'action-button',
45-
'action-animate',
46-
{'action-jump': !this.props.running && this.props.moveLimit - this.props.commandQueue.length}
48+
<a
49+
className={classNames(
50+
'action-button',
51+
'action-animate',
52+
{ 'action-jump': !this.props.running && this.props.moveLimit - this.props.commandQueue.length }
4753
)}
48-
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('JUMP_UP') }}>
54+
onClick={this.props.running || (this.props.moveLimit - this.props.commandQueue.length < 1) ? null : () => { this.props.queueAction('JUMP_UP') }}
55+
>
4956
<img src='/resources/images/jump.svg' className='action-icon' />
5057
</a>
5158
</div>

client/components/CommandQueue.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@ import * as a from '../reducers/action'
33
import classNames from 'classnames'
44

55
class CommandQueue extends Component {
6-
76
render () {
8-
let commandImgs = {}
7+
const commandImgs = {}
98
commandImgs[a.MOVE_FORWARD] = '/resources/images/move-forward.svg'
109
commandImgs[a.JUMP_UP] = '/resources/images/jump.svg'
1110
commandImgs[a.TURN_LEFT] = '/resources/images/turn-left.svg'
@@ -27,13 +26,11 @@ class CommandQueue extends Component {
2726
>
2827
<img src={commandImgs[e]} />
2928
</div>
30-
)
31-
})
32-
}
29+
)
30+
})}
3331
</div>
3432
)
3533
}
36-
3734
}
3835

3936
export default CommandQueue

client/components/Nav.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import classNames from 'classnames'
55
import levels from '../levels'
66

77
class Nav extends Component {
8-
98
handleKeyPress (e) {
109
if (e.which === 27) {
1110
this.refs.storyBox.hide()
@@ -15,7 +14,7 @@ class Nav extends Component {
1514
}
1615

1716
componentDidMount () {
18-
var cookies = cookie.load('knownUser')
17+
const cookies = cookie.load('knownUser')
1918
// Check if cookie exists. If not, show modal and set cookie.
2019
if (!cookies) {
2120
cookie.save('knownUser', 'User has been here before')
@@ -30,18 +29,18 @@ class Nav extends Component {
3029
}
3130

3231
render () {
33-
var modalLeft = '50%'
32+
let modalLeft = '50%'
3433
if (window.innerWidth < 600) {
3534
modalLeft = '41%'
3635
}
37-
var storyAndInstructionsStyle = {
36+
const storyAndInstructionsStyle = {
3837
backgroundColor: '#00897B',
3938
color: '#ffffff',
4039
borderRadius: '2%',
4140
padding: '0 30px 0 30px',
4241
overflowY: 'auto'
4342
}
44-
var levelsModalStyle = {
43+
const levelsModalStyle = {
4544
backgroundColor: '#00897B',
4645
color: '#ffffff',
4746
width: '50%',
@@ -58,8 +57,8 @@ class Nav extends Component {
5857
</div>
5958
</div>
6059
<div className='levels-container'>
61-
<div className='levels' onClick={() => this.refs.levelSelect.show()} >{'Level ' + this.props.currentLevel}</div>
62-
<SkyLight hideOnOverlayClicked={true} ref='levelSelect' dialogStyles={levelsModalStyle} >
60+
<div className='levels' onClick={() => this.refs.levelSelect.show()}>{'Level ' + this.props.currentLevel}</div>
61+
<SkyLight hideOnOverlayClicked ref='levelSelect' dialogStyles={levelsModalStyle}>
6362
<div className='about-backstory level-select-container'>
6463
<h3 className={classNames('modal-heading', 'about-backstory')}>Select a level</h3>
6564
{
@@ -80,9 +79,9 @@ class Nav extends Component {
8079
</SkyLight>
8180
<div className='about' onClick={() => this.refs.storyBox.show()}>i</div>
8281
<div className='sound' onClick={this.props.toggleSound}>
83-
{this.props.sound ? <i className='fa fa-volume-up fa-lg'></i> : <i className='fa fa-volume-off fa-lg'></i>}
82+
{this.props.sound ? <i className='fa fa-volume-up fa-lg' /> : <i className='fa fa-volume-off fa-lg' />}
8483
</div>
85-
<SkyLight hideOnOverlayClicked={true} ref='storyBox' dialogStyles={storyAndInstructionsStyle} >
84+
<SkyLight hideOnOverlayClicked ref='storyBox' dialogStyles={storyAndInstructionsStyle}>
8685
<div className='about-backstory'>
8786
<img src='/resources/images/intro-b3.svg' className='intro-b3' />
8887
<h3 className={classNames('modal-heading', 'about-backstory')}>Beep Boop</h3>
@@ -94,12 +93,12 @@ class Nav extends Component {
9493
<br />
9594
<div className='modal-button-container'>
9695
<a className='modal-button modal-animate how-to-action' onClick={() => { this.refs.howToPlayBox.show(); this.refs.storyBox.hide() }}>
97-
How to Play
96+
How to Play
9897
</a>
9998
</div>
10099
</div>
101100
</SkyLight>
102-
<SkyLight hideOnOverlayClicked={true} ref='howToPlayBox' dialogStyles={storyAndInstructionsStyle} >
101+
<SkyLight hideOnOverlayClicked ref='howToPlayBox' dialogStyles={storyAndInstructionsStyle}>
103102
<div className='about-backstory'>
104103
<h3 className={classNames('modal-heading', 'about-backstory')}>Your Mission</h3>
105104
<p>Get B3 <img src='/resources/images/b3-robot.svg' className='how-to-small' /> to the elevator <img src='/resources/images/elevator-top.svg' className='how-to-small' /> on each level. </p>

0 commit comments

Comments
 (0)