This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
1.0.0 1.0.1
Alert system with several customization options build purely in elm
version 1.0.1
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.2
Committed At 2017-09-30 00:53:47 UTC
rtfeldman/elm-css-helpers 2.1.0 <= v < 3.0.0 2.1.0
rtfeldman/elm-css 9.0.0 <= v < 10.0.0 9.1.0
mdgriffith/elm-style-animation 3.5.5 <= v < 4.0.0 3.5.5
elm-lang/svg 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
damienklinnert/elm-spinner 3.0.1 <= v < 4.0.0 3.0.2

README

elm-alerts

This is an alert message library for Elm.

Currently it forces use to use default Html for alerts, perhaps at some point I will separate the default into a submodule and allow custom Html.

Usage

Add alerts to your model

type alias Model =
    { ...
    , alerts : Alert.Model
    }

Initialize alerts in your model

initModel : Model
initModel =
    { ...
    , alerts = Alert.initModel True
    }

Add alerts in your messages

type Msg
    = ...
    | AlertMsg Alert.Msg

Add alerts to your view

view : Model -> Html Msg
view model =
    div []
        [ ...
        , Html.map AlertMsg <| Alert.view model.alerts
        ]

Add alerts subscriptions

subscriptions : Model -> Sub Msg
subscriptions model =
    Sub.batch
        [ ...
        , Sub.map AlertMsg <| Alert.subscriptions model.alerts
        ]

Handle alert updates

update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        ... ->
        AlertMsg alertMsg ->
            let
                ( alerts, cmd ) =
                    Alert.update alertMsg model.alerts
            in
                ( { model | alerts = alerts }
                , Cmd.map AlertMsg cmd
                )

Examples

Example of how to display an alert

button
    [ onClick <|
        AlertMsg <|
            Alert.AddAlert
                { type_ = Alert.Error
                , message = model.message
                , untilRemove = model.untilRemove
                , icon = model.icon
                }
    ]
    [ text "Error" ]

For a more complete example see the examples folder.