aboutsummaryrefslogtreecommitdiff
path: root/src/main.ts
diff options
context:
space:
mode:
authorJoris2023-02-13 15:25:56 +0100
committerJoris2023-02-13 21:34:38 +0100
commitffca3dfb15f37999d2b751c5b62a90ead65201a3 (patch)
tree62f2b0429ea6f8aaa328d41da7b623439142e75b /src/main.ts
parenta1960c7e10691e460b835446bb358c27e971fba8 (diff)
downloadchords-ffca3dfb15f37999d2b751c5b62a90ead65201a3.tar.gz
chords-ffca3dfb15f37999d2b751c5b62a90ead65201a3.tar.bz2
chords-ffca3dfb15f37999d2b751c5b62a90ead65201a3.zip
Use rx to update the view
Diffstat (limited to 'src/main.ts')
-rw-r--r--src/main.ts33
1 files changed, 30 insertions, 3 deletions
diff --git a/src/main.ts b/src/main.ts
index aecb754..bba799e 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -1,4 +1,31 @@
-import * as form from 'view/form'
-import * as dom from 'lib/dom'
+import { h, withVar, mount } from 'lib/rx'
+import * as Form from 'view/form'
+import * as Play from 'view/play'
+import * as Options from 'view/options'
-dom.show(form.view())
+enum Page {
+ Form,
+ Play
+}
+
+mount(
+ withVar(Page.Form, (page, updatePage) => [
+ h('header',
+ { onclick: () => updatePage(_ => Page.Form) },
+ 'Chords'
+ ),
+ page.map(p =>
+ p === Page.Form
+ ? Form.view({
+ options: Options.load(),
+ onSubmit: (options: Options.Model) => {
+ Options.save(options)
+ updatePage(_ => Page.Play)
+ }
+ })
+ : Play.view({
+ options: Options.load()
+ })
+ )
+ ])
+)