Write a basic view function. Without styling, it's impossible to see.
Šī revīzija ir iekļauta:
26
Go/View.elm
Parasts fails
26
Go/View.elm
Parasts fails
@@ -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
|
||||
Atsaukties uz šo jaunā problēmā
Block a user