This page covers Elm 0.18
Players List
Create src/Players/List.elm
module Players.List exposing (..)
import Html exposing (..)
import Html.Attributes exposing (class)
import Players.Messages exposing (..)
import Players.Models exposing (Player)
view : List Player -> Html Msg
view players =
div []
[ nav players
, list players
]
nav : List Player -> Html Msg
nav players =
div [ class "clearfix mb2 white bg-black" ]
[ div [ class "left p2" ] [ text "Players" ] ]
list : List Player -> Html Msg
list players =
div [ class "p2" ]
[ table []
[ thead []
[ tr []
[ th [] [ text "Id" ]
, th [] [ text "Name" ]
, th [] [ text "Level" ]
, th [] [ text "Actions" ]
]
]
, tbody [] (List.map playerRow players)
]
]
playerRow : Player -> Html Msg
playerRow player =
tr []
[ td [] [ text player.id ]
, td [] [ text player.name ]
, td [] [ text (toString player.level) ]
, td []
[]
]
This view shows a list of players.