-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathView.elm
54 lines (41 loc) · 932 Bytes
/
View.elm
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module View exposing (view)
import Html exposing (div, text, node)
import Html.Attributes exposing (class, classList, href, id)
import Html.Events exposing (onClick)
import Update exposing (Msg(..))
view model =
div
[]
[ viewLevel model.level
, viewMoves model.moves
, viewGrid model.grid
]
viewLevel level =
div
[ id "level" ]
[ text "Level: "
, text (toString (level + 1))
]
viewMoves moves =
div
[ id "moves" ]
[ text "Moves: "
, text (toString moves)
]
viewGrid grid =
div
[ id "grid" ]
(List.indexedMap viewRow grid)
viewRow y row =
div
[ class "row" ]
(List.indexedMap (viewCell y) row)
viewCell y x on =
div
[ onClick (Toggle x y)
, classList
[ ( "cell", True )
, ( "on", on )
]
]
[]