Move stuff
This commit is contained in:
40
intro-to-elm/part8/src/Views/Form.elm
Normal file
40
intro-to-elm/part8/src/Views/Form.elm
Normal file
@@ -0,0 +1,40 @@
|
||||
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 ]
|
||||
Reference in New Issue
Block a user