m3e/nav_menu_item

nav_menu_item provides Lustre support for the M3E Nav Menu Item component

Types

Config holds the configuration for a NavMenuItem

pub type Config {
  Config(
    badge: option.Option(String),
    interaction: types.Interaction,
    leading_icon_name: option.Option(String),
    label: String,
    expansion: Expansion,
    selection: types.SelectionState,
    selected_icon_name: option.Option(String),
    toggle_icon_name: option.Option(String),
  )
}

Constructors

Expansion specifies if an item is open or closed

pub type Expansion {
  Open
  Closed
}

Constructors

  • Open
  • Closed

NavMenuItem represents a navigation menu item

Fields:

  • badge: Renders the badge of the item
  • interaction: Whether the element is enabled or disabled
  • leading_icon_name: Renders the icon of the item
  • label: Renders the label of the item
  • expansion: Whether the item is expanded
  • selection: Whether the element is selected
  • selected_icon_name: Renders the icon of the item when selected
  • toggle_icon_name: Renders the toggle icon
pub opaque type NavMenuItem

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

pub type Slot {
  Badge
  Icon
  Label
  SelectedIcon
  ToggleIcon
}

Constructors

  • Badge
  • Icon
  • Label
  • SelectedIcon
  • ToggleIcon

Values

pub fn badge(
  item: NavMenuItem,
  badge: option.Option(String),
) -> NavMenuItem

badge sets the badge field

pub fn default_config(label: String) -> Config

default_config creates a new Config with default values

pub const default_expansion: Expansion
pub fn disabled(
  item: NavMenuItem,
  interaction: types.Interaction,
) -> NavMenuItem

disabled sets the interaction field

pub fn from_config(c: Config) -> NavMenuItem

from_config creates a NavMenuItem from a Config record

pub fn label(item: NavMenuItem, label: String) -> NavMenuItem

label sets the label field

pub fn leading_icon_name(
  item: NavMenuItem,
  leading_icon_name: option.Option(String),
) -> NavMenuItem

leading_icon_name sets the leading_icon_name field

pub fn new(label: String) -> NavMenuItem

new creates a nav-menu-item with default values

Parameters:

  • label: Renders the label of the item
pub fn open(
  item: NavMenuItem,
  expansion: Expansion,
) -> NavMenuItem

open sets the expansion field

pub fn render(
  item: NavMenuItem,
  attributes: List(attribute.Attribute(msg)),
) -> element.Element(msg)

render creates a Lustre Element(msg) from a NavMenuItem

Parameters:

  • item: a NavMenuItem
  • attributes: additional attributes
pub fn render_config(
  config: Config,
  attributes: List(attribute.Attribute(msg)),
) -> element.Element(msg)

render_config creates a Lustre Element directly from a Config

pub fn selected(
  item: NavMenuItem,
  selection: types.SelectionState,
) -> NavMenuItem

selected sets the selection field

pub fn selected_icon_name(
  item: NavMenuItem,
  selected_icon_name: option.Option(String),
) -> NavMenuItem

selected_icon_name sets the selected_icon_name field

pub fn slot(s: Slot) -> attribute.Attribute(msg)

slot creates a Lustre ‘slot’ Attribute(msg) for a Slot

pub fn toggle_icon_name(
  item: NavMenuItem,
  toggle_icon_name: option.Option(String),
) -> NavMenuItem

toggle_icon_name sets the toggle_icon_name field

Search Document