summaryrefslogtreecommitdiff
path: root/app/client/modules/pix2pix/index.js
blob: 60e49fac694b7afa9a07c23d9d913f1390a4b181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { h, Component } from 'preact'
import { Route, Link } from 'react-router-dom'

import actions from '../../actions'

import util from '../../util'

import Pix2PixNew from './views/pix2pix.new'
import Pix2PixShow from './views/pix2pix.show'
import Pix2PixLive from './views/pix2pix.live'

class router {
  componentWillMount(){
    actions.system.changeTool('pix2pix')
    document.body.style.backgroundImage = 'linear-gradient(' + (util.randint(40)+40) + 'deg, #fde, #ffe)'
  }
  componentWillReceiveProps(){
    actions.system.changeTool('pix2pix')
    document.body.style.backgroundImage = 'linear-gradient(' + (util.randint(40)+40) + 'deg, #fde, #ffe)'
  }
  render(){
    return (
      <section>
        <Route exact path='/pix2pix/new/' component={Pix2PixNew} />
        <Route exact path='/pix2pix/sequences/' component={Pix2PixShow} />
        <Route exact path='/pix2pix/sequences/:id/' component={Pix2PixShow} />
        <Route exact path='/pix2pix/live/' component={Pix2PixLive} />
      </section>
    )
  }
}

function links(){
  return [
    { url: '/pix2pix/new/', name: 'new' },
    { url: '/pix2pix/sequences/', name: 'sequences' },
    { url: '/pix2pix/live/', name: 'live' },
  ]
}

export default {
  name: 'pix2pix',
  router, links,
}