aboutsummaryrefslogtreecommitdiff
path: root/src/main.ts
blob: e588aabf1feb920f82397bad199e2fbacee4c867 (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
import { h, withState, mount } from 'lib/rx'
import * as Form from 'view/form'
import * as Play from 'view/play'
import * as Options from 'view/options'

enum Page {
  Form,
  Play
}

mount(
  withState(Page.Form, page => [
    h('header',
      { onclick: () => page.update(_ => Page.Form) },
      'Chords'
    ),
    page.map(p =>
      p === Page.Form
        ? Form.view({
            options: Options.load(),
            onSubmit: (options: Options.Model) => {
              Options.save(options)
              page.update(_ => Page.Play)
            }
          })
        : Play.view({
          options: Options.load()
        })
    )
  ])
)