Orasund / elm-ui-widgets / Widget.Snackbar

Snackbar

A snackbar shows notification, one at a time.

Basics


type alias SnackbarStyle msg =
{ elementRow : List (Element.Attribute msg)
, content : { text : { elementText : List (Element.Attribute msg) }
, button : Internal.Button.ButtonStyle msg } 
}


type alias Snackbar a =
{ queue : Queue ( a
, Basics.Int )
, current : Maybe ( a
, Basics.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 (Internal.Button.TextButton msg) 
}

A message with maybe some action button

init : Snackbar a

Initial state

current : Snackbar a -> Maybe a

Returns the current element.

timePassed : Basics.Int -> Snackbar a -> Snackbar a

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

view : 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 : Basics.Int -> a -> Snackbar a -> Snackbar a

Insert a message for a specific amount of milliseconds.

dismiss : Snackbar a -> Snackbar a

Dismiss the current message.