Files
elm-0.19-workshop/part7/src/Views/Errors.elm
Richard Feldman c34810f421 Add part7
2018-05-05 08:04:50 -04:00

30 lines
755 B
Elm

module Views.Errors exposing (view)
{-| Render dismissable errors. We use this all over the place!
-}
import Html exposing (..)
import Html.Attributes exposing (class, style)
import Html.Events exposing (onClick)
view : msg -> List String -> Html msg
view dismissErrors errors =
if List.isEmpty errors then
Html.text ""
else
div [ class "error-messages", styles ] <|
List.map (\error -> p [] [ text error ]) errors
++ [ button [ onClick dismissErrors ] [ text "Ok" ] ]
styles : Attribute msg
styles =
style
[ ( "position", "fixed" )
, ( "top", "0" )
, ( "background", "rgb(250, 250, 250)" )
, ( "padding", "20px" )
, ( "border", "1px solid" )
]