diff options
author | Joris | 2020-03-03 10:44:35 +0100 |
---|---|---|
committer | Joris | 2020-03-03 10:44:35 +0100 |
commit | 5c636f11cdfed82634ee572645d765b704941b68 (patch) | |
tree | 51e11a0cfbbab284985e98fcb558d2975209a9b2 /src/main.ml | |
parent | a2880850a78fc36e2612215c83cbdeac0c980a5b (diff) |
Initialize views from JavaScript
Diffstat (limited to 'src/main.ml')
-rw-r--r-- | src/main.ml | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/src/main.ml b/src/main.ml index e399e3b..003880b 100644 --- a/src/main.ml +++ b/src/main.ml @@ -1,18 +1,14 @@ -let onTimerStart () = - Animation.start - ~onHidden:(fun () -> - let () = Config.hide () in - let () = Timer.init () in - Timer.show ()) - ~onEnded:Timer.start - -let onTimerStop () = - Animation.start - ~onHidden:(fun () -> - let () = Timer.hide () in - Config.show ()) - ~onEnded:(fun () -> ()) +type view = Config of Config.config | Timer of Config.config let () = - let () = Config.setup onTimerStart in - Timer.setup onTimerStop + let html = Document.querySelectorUnsafe "html" in + let main = Document.querySelectorUnsafe "main" in + let rec showView v = + Animation.replaceChild html main (fun _ -> + match v with + | Config config -> + ConfigView.render config (fun config -> showView (Timer config)) + | Timer config -> + TimerView.render config (fun config -> showView (Config config))) + in + showView (Config Config.init) |