Orasund/elm-ui-widgets/2.0.3

NOTE: the latest version is 3.4.0

Widget.Snackbar

Snackbar

A snackbar shows notification, one at a time.

Open in Ellie

Basics

type alias Snackbar a =
{ queue : Queue ( a, Int )
, current : Maybe ( a, Int )
}

A snackbar has a queue of Notifications, each with the amount of ms the message should be displayed

type alias Message msg =
{ text : String
, button : Maybe (TextButton msg)
}

A message with maybe some action button

init : Snackbar a

Inital state

current : Snackbar a -> Maybe a

Returns the current element.

timePassed : Int -> Snackbar a -> Snackbar a

Updates the model. This functions should be called regularly. The first argument is the milli seconds that passed since the last time the function was called.

SnackbarStyle msg
-> (a -> Message msg)
-> Snackbar a
-> Maybe (Element msg)

Views the current Message. (only one at a time)

Operations

insert : a -> Snackbar a -> Snackbar a

Insert a message that will last for 10 seconds.

insertFor : Int -> a -> Snackbar a -> Snackbar a

Insert a message for a specific amount of milli seconds.

dismiss : Snackbar a -> Snackbar a

Dismiss the current message.