Write a basic view function. Without styling, it's impossible to see.

This commit is contained in:
2018-05-25 12:06:15 -07:00
parent 0283e060e4
commit 43ad995c62
5 changed files with 40 additions and 6 deletions

26
Go/View.elm Normal file
View File

@@ -0,0 +1,26 @@
module Go.View exposing (..)
import Go.Util exposing (allIndices, pair, lookup)
import Go.Types exposing (..)
import Html exposing (Html, div, text, p)
import Html.Attributes exposing (class, classList)
import Html.Events exposing (onClick)
renderIndex : (Index, Maybe Color) -> Html Msg
renderIndex (index, color) =
let
extraClass = case color of
Just c -> (if c == Black then "black-cell" else "white-cell", True)
Nothing -> ("", False)
in
div [ classList [ ("board-cell", True), extraClass ]
, onClick (Place index)
]
[
]
renderBoard : Int -> Board -> Html Msg
renderBoard size board =
let
cells = List.map (\i -> (lookup i board) |> (pair i)) <| allIndices size
in
div [] <| List.map renderIndex cells