Skip to content

Commit 0caf826

Browse files
committed
Standardize
1 parent 26df5c3 commit 0caf826

File tree

3 files changed

+57
-72
lines changed

3 files changed

+57
-72
lines changed

next.config.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,7 @@
11
module.exports = {
22
exportPathMap () {
33
return {
4-
"/": { page: "/" },
4+
'/': { page: '/' }
55
}
6-
},
7-
webpack: function (config, { dev }) {
8-
// For the development version, we'll use React.
9-
// Because, it supports react hot loading and so on.
10-
// if (dev) {
11-
return config
12-
// }
13-
14-
config.resolve.alias = {
15-
'react': 'preact-compat',
16-
'react-dom': 'preact-compat'
17-
}
18-
19-
return config
206
}
217
}

pages/index.js

Lines changed: 54 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import KeyHandler, {KEYDOWN} from 'react-key-handler'
2-
import {CSSTransition, TransitionGroup} from 'react-transition-group'
1+
import KeyHandler, { KEYDOWN } from 'react-key-handler'
2+
import { CSSTransition, TransitionGroup } from 'react-transition-group'
33
import React from 'react'
44
import Swipeable from 'react-swipeable'
55
import Head from 'next/head'
@@ -23,7 +23,7 @@ const thresholds = [0, 0, 5, 30, 90, 150, 230, 280, 350, 450]
2323

2424
var dotsId = 0
2525

26-
const Dot = ({x, y, type, floating}) => (
26+
const Dot = ({ x, y, type, floating }) => (
2727
<div
2828
style={{
2929
position: 'absolute',
@@ -38,7 +38,7 @@ const Dot = ({x, y, type, floating}) => (
3838
/>
3939
)
4040

41-
const Levels = ({current}) => {
41+
const Levels = ({ current }) => {
4242
return (
4343
<div
4444
style={{
@@ -91,9 +91,10 @@ class Page extends React.Component {
9191
x,
9292
y,
9393
key: dotsId++,
94-
type: level !== undefined
95-
? level
96-
: Math.floor(Math.random() * this.state.level)
94+
type:
95+
level !== undefined
96+
? level
97+
: Math.floor(Math.random() * this.state.level)
9798
}
9899
}
99100
moveDotsLeft () {
@@ -176,7 +177,7 @@ class Page extends React.Component {
176177
if (d.y === min.y && d.x < min.x) return d
177178
return min
178179
},
179-
{x: 10, y: -2}
180+
{ x: 10, y: -2 }
180181
)
181182

182183
if (newColoredDot.type < colors.length - 1) {
@@ -190,7 +191,7 @@ class Page extends React.Component {
190191
}
191192
l.forEach((d, i) => {
192193
keep[d.x][d.y] = false
193-
this.updateScore(this.state.score + ((newColoredDot.type + 1) * 5))
194+
this.updateScore(this.state.score + (newColoredDot.type + 1) * 5)
194195
})
195196
this.state.blocksKilled++
196197
}
@@ -232,12 +233,12 @@ class Page extends React.Component {
232233
if (typeof window === 'undefined') return
233234
const highScore = Math.max(score, this.state.highScore)
234235
window.localStorage['score'] = highScore
235-
this.setState({highScore, score})
236+
this.setState({ highScore, score })
236237
}
237238

238239
loadHighScore () {
239240
if (typeof window === 'undefined') return
240-
return this.setState({highScore: window.localStorage['score'] || 0})
241+
return this.setState({ highScore: window.localStorage['score'] || 0 })
241242
}
242243

243244
pushDots () {
@@ -383,13 +384,12 @@ class Page extends React.Component {
383384
render () {
384385
return (
385386
<Swipeable onSwiped={this.swiped.bind(this)}>
386-
387387
<Head>
388388
<title>Combine!</title>
389-
<meta charSet='utf-8' />
389+
<meta charSet="utf-8" />
390390
<meta
391-
name='viewport'
392-
content='initial-scale=1.0, width=device-width'
391+
name="viewport"
392+
content="initial-scale=1.0, width=device-width"
393393
/>
394394
</Head>
395395

@@ -408,51 +408,51 @@ class Page extends React.Component {
408408
}}
409409
>
410410
<style jsx global>{`
411-
.example-enter {
412-
transform: scale(1.7);
413-
border-radius: 0% !important;
414-
opacity: 0.01;
415-
z-index: 2;
416-
}
411+
.example-enter {
412+
transform: scale(1.7);
413+
border-radius: 0% !important;
414+
opacity: 0.01;
415+
z-index: 2;
416+
}
417417
418-
.example-enter.example-enter-active {
419-
opacity: 1;
420-
transform: scale(1);
421-
border-radius: 50% !important;
422-
transition: 0.3s !important;
423-
z-index: 2;
424-
}
418+
.example-enter.example-enter-active {
419+
opacity: 1;
420+
transform: scale(1);
421+
border-radius: 50% !important;
422+
transition: 0.3s !important;
423+
z-index: 2;
424+
}
425425
426-
.example-exit {
427-
opacity: 1;
428-
}
426+
.example-exit {
427+
opacity: 1;
428+
}
429429
430-
.example-exit.example-exit-active {
431-
opacity: 0.01;
432-
border-radius: 0% !important;
433-
transform: scale(0.7);
434-
transition: 0.4s !important;
435-
}
436-
`}</style>
430+
.example-exit.example-exit-active {
431+
opacity: 0.01;
432+
border-radius: 0% !important;
433+
transform: scale(0.7);
434+
transition: 0.4s !important;
435+
}
436+
`}</style>
437437

438438
<KeyHandler
439439
keyEventName={KEYDOWN}
440-
keyValue='ArrowDown'
440+
keyValue="ArrowDown"
441441
onKeyHandle={() => this.pushDots()}
442442
/>
443443
<KeyHandler
444444
keyEventName={KEYDOWN}
445-
keyValue='ArrowLeft'
445+
keyValue="ArrowLeft"
446446
onKeyHandle={() => this.moveDotsLeft()}
447447
/>
448448
<KeyHandler
449449
keyEventName={KEYDOWN}
450-
keyValue='ArrowRight'
450+
keyValue="ArrowRight"
451451
onKeyHandle={() => this.moveDotsRight()}
452452
/>
453453
<KeyHandler
454454
keyEventName={KEYDOWN}
455-
keyValue='ArrowUp'
455+
keyValue="ArrowUp"
456456
onKeyHandle={() => this.rotateDots()}
457457
/>
458458

@@ -486,8 +486,8 @@ class Page extends React.Component {
486486
whiteSpace: 'nowrap'
487487
}}
488488
>
489-
<div>SCORE: { this.state.score }</div>
490-
<div>HIGHSCORE: { this.state.highScore }</div>
489+
<div>SCORE: {this.state.score}</div>
490+
<div>HIGHSCORE: {this.state.highScore}</div>
491491
</div>
492492
<div
493493
style={{
@@ -509,16 +509,18 @@ class Page extends React.Component {
509509
<TransitionGroup>
510510
{this.state.dots
511511
.concat(
512-
this.state.floatingDots.map(i => ({...i, floating: true}))
512+
this.state.floatingDots.map(i => ({ ...i, floating: true }))
513513
)
514514
.map((params, i) => {
515-
return <CSSTransition
516-
key={params.key}
517-
classNames='example'
518-
timeout={{enter: 300, exit: 400}}
519-
>
520-
<Dot {...params} />
521-
</CSSTransition>
515+
return (
516+
<CSSTransition
517+
key={params.key}
518+
classNames="example"
519+
timeout={{ enter: 300, exit: 400 }}
520+
>
521+
<Dot {...params} />
522+
</CSSTransition>
523+
)
522524
})}
523525
</TransitionGroup>
524526
</div>
@@ -529,4 +531,3 @@ class Page extends React.Component {
529531
}
530532

531533
export default () => <Page />
532-

server.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,11 @@ const next = require('next')
1616
const app = next({ dev })
1717
const handle = app.getRequestHandler()
1818

19-
app.prepare()
20-
.then(() => {
19+
app.prepare().then(() => {
2120
createServer((req, res) => {
2221
const parsedUrl = parse(req.url, true)
2322
handle(req, res, parsedUrl)
24-
})
25-
.listen(port, (err) => {
23+
}).listen(port, err => {
2624
if (err) throw err
2725
console.log(`> Ready on http://localhost:${port}`)
2826
})

0 commit comments

Comments
 (0)