aboutsummaryrefslogtreecommitdiff
path: root/src/View/configView.ml
diff options
context:
space:
mode:
authorJoris2021-05-13 14:50:51 +0200
committerJoris2021-05-13 14:58:26 +0200
commit221b6451fb4f8559a10e7fefebd13ce125ef29d0 (patch)
tree3ab337b7b2d40e8235f887046a580b0850540f11 /src/View/configView.ml
parent5c636f11cdfed82634ee572645d765b704941b68 (diff)
downloadtabata-221b6451fb4f8559a10e7fefebd13ce125ef29d0.tar.gz
tabata-221b6451fb4f8559a10e7fefebd13ce125ef29d0.tar.bz2
tabata-221b6451fb4f8559a10e7fefebd13ce125ef29d0.zip
Rewrite in TypeScript
BuckleScript is no longer maintained. Choose a widely used techno that will still be maintained in the following years.
Diffstat (limited to 'src/View/configView.ml')
-rw-r--r--src/View/configView.ml83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/View/configView.ml b/src/View/configView.ml
deleted file mode 100644
index 5db6ea5..0000000
--- a/src/View/configView.ml
+++ /dev/null
@@ -1,83 +0,0 @@
-open CreateElement
-open Config
-
-let labelledInput labelValue minValue inputValue update writeDuration =
- label
- ~attributes:[| className "g-Form__Label" |]
- ~eventListeners:
- [|
- onInput (fun e ->
- match
- EventTarget.value (Event.target e)
- |> Option.flatMap Belt.Int.fromString
- with
- | Some n ->
- let () = update n in
- writeDuration ()
- | None -> ());
- |]
- ~children:
- [|
- text labelValue;
- input_
- ~attributes:
- [|
- className "g-Form__Input";
- type_ "number";
- min_ (Js.Int.toString minValue);
- value (Js.Int.toString inputValue);
- |]
- ();
- |]
- ()
-
-let render initialConfig onStart =
- let config = ref initialConfig in
- let duration = text (Duration.prettyPrint (getDuration !config)) in
- let wd () =
- Element.setTextContent duration (Duration.prettyPrint (getDuration !config))
- in
- div
- ~children:
- [|
- header
- ~attributes:[| className "g-Layout__Header" |]
- ~children:[| text "Tabata timer" |]
- ();
- form
- ~attributes:[| className "g-Form" |]
- ~eventListeners:
- [|
- onSubmit (fun e ->
- let () = Event.preventDefault e in
- onStart !config);
- |]
- ~children:
- [|
- labelledInput "prepare" 0 !config.prepare
- (fun n -> config := { !config with prepare = n })
- wd;
- labelledInput "tabatas" 1 !config.tabatas
- (fun n -> config := { !config with tabatas = n })
- wd;
- labelledInput "cycles" 1 !config.cycles
- (fun n -> config := { !config with cycles = n })
- wd;
- labelledInput "work" 5 !config.work
- (fun n -> config := { !config with work = n })
- wd;
- labelledInput "rest" 5 !config.rest
- (fun n -> config := { !config with rest = n })
- wd;
- div
- ~attributes:[| className "g-Form__Duration" |]
- ~children:[| text "duration"; div ~children:[| duration |] () |]
- ();
- button
- ~attributes:[| className "g-Form__Start" |]
- ~children:[| text "start" |]
- ();
- |]
- ();
- |]
- ()