grille_pain/toast

grille_pain/toast defines the different side-effects to use to display toasts. They should be used when your outside of lustre applications. Otherwise you should head up to grille_pain/lustre/toast.

Types

Options type allow to modify timeout or level at the notification level directly. This is used to create custom toasts and override defaults. If you don’t need custom toasts, you should head up to default functions (toast, info, success, error and warning).

It follows the Builder pattern.

import grille_pain/toast
import grille_pain/toast/level

fn custom_toast() {
  toast.options()
  |> toast.timeout(millisecond1s: 30_000)
  |> toast.level(level.Warning)
  |> toast.custom("Oops")
}
pub opaque type Options

Functions

pub fn custom(options: Options, content: String) -> Nil
pub fn error(content: String) -> Nil
pub fn info(content: String) -> Nil
pub fn level(options: Options, level: Level) -> Options

Level of your toast.

pub fn options() -> Options

Default, empty options. Use it to start Builder.

pub fn success(content: String) -> Nil
pub fn timeout(
  options: Options,
  milliseconds timeout: Int,
) -> Options

Timeout to override defaults. Accepts a timeout in milliseconds.

pub fn toast(content: String) -> Nil
pub fn warning(content: String) -> Nil
Search Document