Skip to content
This repository has been archived by the owner on Nov 27, 2018. It is now read-only.

Display toast notifications (success, info, warning, alert) in Elm

License

Notifications You must be signed in to change notification settings

KtorZPersonal/elm-notification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

elm-notification

Easily display toast notifications to users. The module defines four common alert levels (success, info, warning and error) and takes care of managing toast lifecycles.

See the demo to get a nice overview of the capabilities.

Install it

elm package install KtorZ/elm-notification

Use it

Within your app, first connect the effects runner to a port (or alternatively, merged it into one of your effects signal that is already bound to a port).

port notifications : Signal (Task Effects.Never ())
port notifications =
  Notification.task

Then, fold on the view signal and display a view accordingly:

view : Html -> Html
view notifications =
  div [] [notifications] 

main =
  Signal.map view Notification.view

To actually send a notification, use the address provided by the module:

view : Html -> Html
view notifications =
  let
    controls = button [onClick Notification.address (Notification.info "Elm rocks!")] [text "Go"]
  in
    div [] [notifications, controls]

TODOs

  • Allow colors and easing animations to be configured

Change log

1.0.0 (2016-04-27)

  • First version, display notifications of four different types

About

Display toast notifications (success, info, warning, alert) in Elm

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages