Skip to content

Commit

Permalink
convert everything to es6 classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vinnymac committed Jan 14, 2017
1 parent c2e784d commit ed72401
Show file tree
Hide file tree
Showing 30 changed files with 510 additions and 817 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"no-use-before-define": 0,
"import/no-unresolved": [2, { "ignore": ["electron"] }],
"import/no-extraneous-dependencies": 0,
"react/prefer-es6-class": [2, "never"],
"react/prefer-es6-class": [2, "always"],
"react/jsx-no-bind": 0,
"react/jsx-filename-extension": [2, { "extensions": [".js", ".jsx"] }],
"react/prefer-stateless-function": 0,
Expand Down
10 changes: 5 additions & 5 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import {

import './app.global.css'

const App = React.createClass({
propTypes: {
class App extends React.Component {
static propTypes = {
authenticate: PropTypes.object.isRequired,
autoLogin: PropTypes.bool.isRequired,
login: PropTypes.func.isRequired,
},
}

componentDidMount() {
const {
Expand All @@ -36,14 +36,14 @@ const App = React.createClass({
if (autoLogin && credentials.method && credentials.password && credentials.username) {
this.props.login(credentials)
}
},
}

render() {
if (this.props.authenticate.loggedIn) return (<Table />)

return (<Login />)
}
})
}

const ConnectedApp = connect((state => ({
authenticate: state.authenticate,
Expand Down
2 changes: 1 addition & 1 deletion app/main.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if (process.env.NODE_ENV === 'production') {

if (process.env.NODE_ENV === 'development') {
require('electron-debug')() // eslint-disable-line global-require
const path = require('path'); // eslint-disable-line
const path = require('path') // eslint-disable-line
const p = path.join(__dirname, '..', 'app', 'node_modules') // eslint-disable-line
require('module').globalPaths.push(p) // eslint-disable-line
}
Expand Down
51 changes: 23 additions & 28 deletions app/screens/ConfirmationDialog/components/SelectedPokemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import React, {
PropTypes
} from 'react'

const SelectedPokemon = React.createClass({
displayName: 'SelectedPokemon',
class SelectedPokemon extends React.Component {
static displayName = 'SelectedPokemon'

propTypes: {
static propTypes = {
pokemon: PropTypes.array
},
}

render() {
const {
Expand Down Expand Up @@ -37,31 +37,26 @@ const SelectedPokemon = React.createClass({
</p>
</div>
)
},

buildRows(pokemon) {
return (
pokemon.map((p, i) => {
const favoriteGlyph = 'glyphicon glyphicon-star favorite-yellow'
const emptyFavoriteGlyph = 'glyphicon glyphicon-star-empty'
const favorite = p.favorite ? favoriteGlyph : emptyFavoriteGlyph

return (
<tr key={i}>
<td>
<span className={`favorite ${favorite}`} />
</td>
<td>{p.name}</td>
<td>{p.nickname}</td>
<td>{p.cp}</td>
<td>{p.iv}%</td>
</tr>
)
})
)
}


})
buildRows = (pokemon) =>
pokemon.map((p, i) => {
const favoriteGlyph = 'glyphicon glyphicon-star favorite-yellow'
const emptyFavoriteGlyph = 'glyphicon glyphicon-star-empty'
const favorite = p.favorite ? favoriteGlyph : emptyFavoriteGlyph

return (
<tr key={i}>
<td>
<span className={`favorite ${favorite}`} />
</td>
<td>{p.name}</td>
<td>{p.nickname}</td>
<td>{p.cp}</td>
<td>{p.iv}%</td>
</tr>
)
})
}

export default SelectedPokemon
22 changes: 11 additions & 11 deletions app/screens/ConfirmationDialog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import React, {
import ReactDOM from 'react-dom'
import SelectedPokemon from './components/SelectedPokemon'

const ConfirmationDialog = React.createClass({
displayName: 'ConfirmationDialog',
class ConfirmationDialog extends React.Component {
static displayName = 'ConfirmationDialog'

propTypes: {
static propTypes = {
onClickSecondary: PropTypes.func.isRequired,
onClickPrimary: PropTypes.func.isRequired,
dialog: PropTypes.object.isRequired,
Expand All @@ -16,11 +16,11 @@ const ConfirmationDialog = React.createClass({
title: PropTypes.string.isRequired,
message: PropTypes.string.isRequired,
pokemon: PropTypes.array
},
}

componentDidMount() {
this.props.dialog.modal('show')
},
}

render() {
const {
Expand Down Expand Up @@ -55,7 +55,7 @@ const ConfirmationDialog = React.createClass({
data-dismiss="modal"
aria-label="Close"
>
<span aria-hidden="true">&times;</span>
<span aria-hidden="true">&times</span>
</button>
<h4 className="modal-title" id="confirmationDialogLabel">
{title}
Expand Down Expand Up @@ -87,18 +87,18 @@ const ConfirmationDialog = React.createClass({
</div>
</div>
)
},
}

handleSecondary() {
handleSecondary = () => {
this.props.dialog.modal('hide')
this.props.onClickSecondary()
},
}

handlePrimary() {
handlePrimary = () => {
this.props.dialog.modal('hide')
this.props.onClickPrimary()
}
})
}

export default ($modal, props) => {
props.dialog = $modal
Expand Down
12 changes: 6 additions & 6 deletions app/screens/Detail/components/CinematicMove.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {

import Tooltip from '../../Tooltip'

const CinematicMove = React.createClass({
displayName: 'CinematicMove',
class CinematicMove extends React.Component {
static displayName = 'CinematicMove'

propTypes: {
static propTypes = {
move: PropTypes.object.isRequired,
myMove: PropTypes.object.isRequired,
},
}

render() {
const {
Expand Down Expand Up @@ -62,7 +62,7 @@ const CinematicMove = React.createClass({
</div>
</div>
)
},
})
}
}

export default CinematicMove
13 changes: 6 additions & 7 deletions app/screens/Detail/components/Evolutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import React, {

import utils from '../../../utils'

const QuickMove = React.createClass({
displayName: 'Evolutions',
class QuickMove extends React.Component {
static displayName = 'Evolutions'

propTypes: {
static propTypes = {
evolutionIds: PropTypes.node.isRequired
},
}

render() {
const {
Expand Down Expand Up @@ -47,8 +47,7 @@ const QuickMove = React.createClass({
{evolveInfoItems}
</div>
)
},

})
}
}

export default QuickMove
15 changes: 7 additions & 8 deletions app/screens/Detail/components/ModalBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import CinematicMove from './CinematicMove'
import Nickname from './Nickname'
import Evolutions from './Evolutions'

const ModalBody = React.createClass({
propTypes: {
class ModalBody extends React.Component {
static propTypes = {
transform: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
hp: PropTypes.string.isRequired,
Expand All @@ -26,7 +26,7 @@ const ModalBody = React.createClass({
evolutionIds: PropTypes.node,
possibleQuickMoves: PropTypes.array,
possibleCinematicMoves: PropTypes.array,
},
}

render() {
const {
Expand Down Expand Up @@ -145,12 +145,11 @@ const ModalBody = React.createClass({
<Evolutions evolutionIds={evolutionIds} />
</div>
</div>)
},
}

handleCry() {
handleCry = () => {
this.cry.play()
},

})
}
}

export default ModalBody
33 changes: 15 additions & 18 deletions app/screens/Detail/components/Nickname.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,16 @@ function getNumberInCircle(num) {
return `${num}`
}

const Nickname = React.createClass({
propTypes: {
class Nickname extends React.Component {
static propTypes = {
pokemon: PropTypes.object.isRequired,
renamePokemon: PropTypes.func.isRequired
},
}

getInitialState() {
return {
newNickname: this.props.pokemon.nickname,
editing: false
}
},
state = {
newNickname: this.props.pokemon.nickname,
editing: false
}

componentDidUpdate() {
if (this.state.editing) {
Expand All @@ -36,7 +34,7 @@ const Nickname = React.createClass({
} else if (this.lastActiveElement) {
this.lastActiveElement.focus()
}
},
}

render() {
const {
Expand Down Expand Up @@ -69,15 +67,15 @@ const Nickname = React.createClass({
/>
</div>
)
},
}

handleEdit() {
handleEdit = () => {
this.setState({
editing: true
})
},
}

handleKeyPress(e) {
handleKeyPress = (e) => {
const {
pokemon,
} = this.props
Expand Down Expand Up @@ -112,9 +110,9 @@ const Nickname = React.createClass({
this.handleRenameComplete(updatedPokemon)
})
}
},
}

handleRenameComplete(updatedPokemon) {
handleRenameComplete = (updatedPokemon) => {
const {
pokemon
} = this.props
Expand All @@ -126,8 +124,7 @@ const Nickname = React.createClass({
editing: false
})
}

})
}

export default connect(null, dispatch => bindActionCreators({
renamePokemon
Expand Down
13 changes: 6 additions & 7 deletions app/screens/Detail/components/QuickMove.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import React, {

import Tooltip from '../../Tooltip'

const QuickMove = React.createClass({
displayName: 'QuickMove',
class QuickMove extends React.Component {
static displayName = 'QuickMove'

propTypes: {
static propTypes = {
move: PropTypes.object.isRequired,
myMove: PropTypes.object.isRequired,
},
}

render() {
const {
Expand Down Expand Up @@ -51,8 +51,7 @@ const QuickMove = React.createClass({
</div>
</div>
)
},

})
}
}

export default QuickMove
Loading

0 comments on commit ed72401

Please sign in to comment.