module Login exposing (Model, Msg, ViewConfig, update, view) import Html exposing (..) import Html.Attributes exposing (..) import Html.Events exposing (onClick, onInput) -- message type Msg = Username String | Password String -- model type alias Model = { username : String , password : String } -- update update : Msg -> Model -> Model update msg model = case msg of Username name -> { model | username = name } Password password -> { model | password = password } -- view type alias ViewConfig msg = { onInternal : Msg -> msg , onLogin : msg } view : Model -> ViewConfig msg -> Html msg view model config = div [] [ input [ type_ "text", placeholder "Username", onInput (config.onInternal << Username) ] [] , br [] [] , input [ type_ "password", placeholder "Password", onInput (config.onInternal << Password) ] [] , br [] [] , br [] [] , button [ onClick config.onLogin ] [ text "Login" ] ]