module View.View ( view ) where import Html (..) import Html.Attributes (..) import Html.Events (..) import Signal import List import Dict import Json.Decode as Json import Debug import Model.Model (..) import Model.Timer (..) import Model.Id (..) import Update.Update (..) import View.Timer (timerView) view : Model -> Html view model = div [] [ h1 [] [ text "Timer" ] , addTimer , model.timers |> Dict.toList |> List.sortBy (.creationTime << snd) |> List.reverse |> timers ] addTimer : Html addTimer = button [ class "addTimer" , onClick (Signal.send updates AddNewTimer) ] [ i [ class "fa fa-fw fa-plus" ] [] ] onEnter : Signal.Message -> Attribute onEnter message = on "keydown" (Json.customDecoder keyCode is13) (always message) is13 : Int -> Result String () is13 code = if code == 13 then Ok() else Err "Not the right key code" timers : List (Id, Timer) -> Html timers timers = div [ class "timers" ] (List.map timerView timers)