m3e/snackbar

snackbar provides Lustre support for the M3E Snackbar component

Types

Config holds the configuration for a Snackbar

pub type Config {
  Config(
    message: String,
    action_label: option.Option(String),
    close_label: option.Option(String),
    dismissibility: types.Dismissibility,
    duration: option.Option(Int),
  )
}

Constructors

Slot gives type-safe names to each of the defined HTML named slots

pub type Slot {
  CloseIcon
}

Constructors

  • CloseIcon

Snackbar presents short updates about application processes at the bottom of the screen

Fields:

  • message: The text to display in the snackbar
  • action_label: The label of the snackbar’s action
  • close_label: The accessible label given to the button used to dismiss the snackbar
  • dismissibility: Whether a button is presented that can be used to close the snackbar
  • duration: The length of time, in milliseconds, to wait before automatically dismissing the snackbar
pub type Snackbar {
  Snackbar(
    message: String,
    action_label: option.Option(String),
    close_label: option.Option(String),
    dismissibility: types.Dismissibility,
    duration: option.Option(Int),
  )
}

Constructors

SnackbarAction describes the intent to open a snackbar with specific parameters. This allows the logic to be pure and easily testable.

pub type SnackbarAction(msg) {
  Open(
    message: String,
    action_label: String,
    dismissable: Bool,
    close_label: String,
    duration: Int,
    callback: option.Option(msg),
  )
}

Constructors

  • Open(
      message: String,
      action_label: String,
      dismissable: Bool,
      close_label: String,
      duration: Int,
      callback: option.Option(msg),
    )

Values

pub fn action_label(
  s: Snackbar,
  action_label: option.Option(String),
) -> Snackbar

action_label sets the action_label field

pub fn close_label(
  s: Snackbar,
  close_label: option.Option(String),
) -> Snackbar

close_label sets the close_label field

pub const default_action_label: String
pub const default_close_label: String
pub fn default_config(message: String) -> Config

default_config creates a new Config with default values

pub const default_duration: Int
pub fn dismissible(
  s: Snackbar,
  d: types.Dismissibility,
) -> Snackbar

dismissible sets the dismissibility field

pub fn duration(
  s: Snackbar,
  duration: option.Option(Int),
) -> Snackbar

duration sets the duration field

pub fn from_config(c: Config) -> Snackbar

from_config creates a Snackbar from a Config record

pub fn message(s: Snackbar, message: String) -> Snackbar

message sets the message field

pub fn new(message: String) -> Snackbar

new creates a new Snackbar

pub fn open(
  s: Snackbar,
  callback: option.Option(msg),
) -> effect.Effect(msg)

open displays a Snackbar. Unlike render() functions in other M3E components, which are called from an application’s view() function, the Snackbar’s open() is called from an application’s update() function.

Parameters:

  • s: a Snackbar
  • callback: the Msg that should be sent when the Action button is clicked
pub fn open_config(
  config: Config,
  callback: option.Option(msg),
) -> effect.Effect(msg)

open_config displays a Snackbar directly from a Config

Search Document