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

Šī revīzija ir iekļauta:
2018-05-25 12:06:15 -07:00
vecāks 0283e060e4
revīzija 43ad995c62
5 mainīti faili ar 40 papildinājumiem un 6 dzēšanām

26
Go/View.elm Parasts fails
Parādīt failu

@@ -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