Files
elm-0.19-workshop/intro-to-elm/part8/src/Views/Form.elm
Richard Feldman 7793c69762 Move stuff
2018-08-05 04:13:33 -04:00

41 lines
1017 B
Elm

module Views.Form exposing (input, password, textarea, viewErrors)
import Html exposing (Attribute, Html, fieldset, li, text, ul)
import Html.Attributes exposing (class, type_)
password : List (Attribute msg) -> List (Html msg) -> Html msg
password attrs =
control Html.input ([ type_ "password" ] ++ attrs)
input : List (Attribute msg) -> List (Html msg) -> Html msg
input attrs =
control Html.input ([ type_ "text" ] ++ attrs)
textarea : List (Attribute msg) -> List (Html msg) -> Html msg
textarea =
control Html.textarea
viewErrors : List ( a, String ) -> Html msg
viewErrors errors =
errors
|> List.map (\( _, error ) -> li [] [ text error ])
|> ul [ class "error-messages" ]
-- INTERNAL --
control :
(List (Attribute msg) -> List (Html msg) -> Html msg)
-> List (Attribute msg)
-> List (Html msg)
-> Html msg
control element attributes children =
fieldset [ class "form-group" ]
[ element (class "form-control" :: attributes) children ]