m3e/icon_button
icon_button provides Lustre support for the M3E Icon Button component
Types
Config holds the configuration for an IconButton
pub type Config(msg) {
Config(
interaction: Interaction,
form_submission: option.Option(form_submission.FormSubmission),
link: option.Option(link.Link),
purpose: option.Option(attribute.Attribute(msg)),
selection: state.SelectionState,
shape: Shape,
size: config.Size,
toggle: ToggleMode,
variant: Variant,
width: Width,
)
}
Constructors
-
Config( interaction: Interaction, form_submission: option.Option(form_submission.FormSubmission), link: option.Option(link.Link), purpose: option.Option(attribute.Attribute(msg)), selection: state.SelectionState, shape: Shape, size: config.Size, toggle: ToggleMode, variant: Variant, width: Width, )
IconButton(msg) is an icon button users interact with to perform a supplementary action
Fields:
- interaction: Whether the element is enabled or disabled
- form_submission: Whether the element is involved in a form submission
- link: Whether the element is a link
- purpose: A slot value defined by a parent element
- selection: Whether the toggle button is selected
- shape: The shape of the button
- size: The size of the button
- toggle: Whether the button will toggle between selected and unselected states
- variant: The appearance variant of the button
- width: The width of the button
pub opaque type IconButton(msg)
Interaction specifies if the element is enabled or disabled
pub type Interaction {
Enabled
Disabled
DisabledInteractive
}
Constructors
-
Enabled -
Disabled -
DisabledInteractive
Slot gives type-safe names to each of the defined HTML named slots
pub type Slot {
SelectedIcon
}
Constructors
-
SelectedIcon
ToggleMode specifies if the button will toggle between states
pub type ToggleMode {
Toggle
NotToggle
}
Constructors
-
Toggle -
NotToggle
Variant is the appearance variant of the button
pub type Variant {
Filled
Tonal
Outlined
Standard
}
Constructors
-
Filled -
Tonal -
Outlined -
Standard
Values
pub fn default_config() -> Config(msg)
default_config creates a new Config with default values
pub const default_interaction: Interaction
pub const default_shape: Shape
pub const default_toggle: ToggleMode
pub const default_variant: Variant
pub const default_width: Width
pub fn disabled(
i: IconButton(msg),
interaction: Interaction,
) -> IconButton(msg)
disabled sets the interaction field
pub fn form(
i: IconButton(msg),
form: option.Option(form_submission.FormSubmission),
) -> IconButton(msg)
form sets the form_submission field
pub fn from_config(c: Config(msg)) -> IconButton(msg)
from_config creates an IconButton from a Config record
pub fn link(
i: IconButton(msg),
link: option.Option(link.Link),
) -> IconButton(msg)
pub fn purpose(
i: IconButton(msg),
purpose: option.Option(attribute.Attribute(msg)),
) -> IconButton(msg)
purpose sets the purpose field
pub fn render(
i: IconButton(msg),
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
render creates a Lustre Element from an IconButton(msg)
Parameters:
- i: an IconButton(msg)
- attributes: a list of additional Attributes
- children: a list of child Elements
pub fn render_config(
config: Config(msg),
attributes: List(attribute.Attribute(msg)),
children: List(element.Element(msg)),
) -> element.Element(msg)
render_config creates a Lustre Element directly from a Config
pub fn selected(
i: IconButton(msg),
selection: state.SelectionState,
) -> IconButton(msg)
selected sets the selection field
pub fn shape(i: IconButton(msg), shape: Shape) -> IconButton(msg)
shape sets the shape field
pub fn size(
i: IconButton(msg),
size: config.Size,
) -> IconButton(msg)
size sets the size field
pub fn slot(s: Slot) -> attribute.Attribute(msg)
slot creates a Lustre ‘slot’ Attribute(msg) for a Slot
pub fn toggle(
i: IconButton(msg),
toggle: ToggleMode,
) -> IconButton(msg)
toggle sets the toggle field
pub fn variant(
i: IconButton(msg),
variant: Variant,
) -> IconButton(msg)
variant sets the variant field
pub fn width(i: IconButton(msg), width: Width) -> IconButton(msg)
width sets the width field