Skip to content

Commit

Permalink
Status (#1)
Browse files Browse the repository at this point in the history
* Add status

* Add style
  • Loading branch information
edwinans authored May 11, 2024
1 parent 298c0b5 commit bbae25a
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bin/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,9 @@ let update ({camels; size; grid; state; generated; _} as model) = function
Vdom.return ~c:[Vdom.Cmd.echo Reveal_all] model


let s = Vdom.style

let button model (i, j) =
let s = Vdom.style in
let txt =
match model.grid.(i).(j), model.state.(i).(j) with
| Camel, Revealed -> camel_string
Expand All @@ -187,6 +188,15 @@ let button model (i, j) =
]
[Vdom.text txt]

let status {camels; flagged_camels; _} =
Vdom.elt "p"
~a:[
s"margin-top" "1%";
]
[Vdom.text
(Printf.sprintf "%s / %s = %d / %d" cactus_string camel_string flagged_camels camels)
]

let view ({grid; _} as model) =
let buttons =
Array.mapi (fun i row ->
Expand All @@ -199,8 +209,11 @@ let view ({grid; _} as model) =
) grid
|> Array.to_list
in
Vdom.div
buttons
Vdom.div [
Vdom.div buttons;
status model;
]


let _ =
let app = Vdom.app ~init ~update ~view () in
Expand Down

0 comments on commit bbae25a

Please sign in to comment.