m3e/chip

chip provides Lustre support for the M3E Chip components

Types

Behaviour controls the behavior of an assist or suggestion chip

pub type Behaviour {
  Normal
  Reset
  Submit
}

Constructors

  • Normal
  • Reset
  • Submit

Chip provides expressive, accessible chip components for actions, input, filtering, and suggestions

  • label: text on the chip
  • behaviour: behaviour of an Assist or Suggestion chip
  • interaction: whether the Chip is enabled or disabled
  • form_submission: handles this element’s role in form submission
  • icon: associated Icon
  • removability: whether the chip can be removed
  • selection: whether the chip is selected or not
  • type_: the type of Chip
  • variant: variant of the chip
pub opaque type Chip(msg)

Config holds the configuration for a Chip

pub type Config(msg) {
  Config(
    label: String,
    behaviour: Behaviour,
    interaction: types.Interaction,
    form_submission: option.Option(form_submission.FormSubmission),
    icon: option.Option(icon.Icon(msg)),
    removability: Removability,
    selection: types.SelectionState,
    type_: Type,
    variant: Variant,
  )
}

Constructors

Removability specifies if a chip can be removed

pub type Removability {
  Removable
  Permanent
}

Constructors

  • Removable
  • Permanent

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

pub type Slot {
  AssistIcon
  ChipIcon
  ChipTrailingIcon
  FilterIcon
  FilterTrailingIcon
  InputAvatar
  InputIcon
  InputRemoveIcon
  InputSetInput
  SuggestionIcon
}

Constructors

  • AssistIcon
  • ChipIcon
  • ChipTrailingIcon
  • FilterIcon
  • FilterTrailingIcon
  • InputAvatar
  • InputIcon
  • InputRemoveIcon
  • InputSetInput
  • SuggestionIcon

Type of chip

pub type Type {
  Assist
  Filter
  Information
  Input
  Suggestion
}

Constructors

  • Assist
  • Filter
  • Information
  • Input
  • Suggestion

Variant is the style of chip

pub type Variant {
  Elevated
  Outlined
}

Constructors

  • Elevated
  • Outlined

Values

pub fn assist(label: String) -> Chip(msg)

assist creates a basic Assist Chip

pub fn behaviour(c: Chip(msg), behaviour: Behaviour) -> Chip(msg)

behaviour sets the behaviour field

pub const default_behaviour: Behaviour
pub fn default_config() -> Config(msg)

default_config creates a new Config with default values

pub const default_removability: Removability
pub const default_type: Type
pub const default_variant: Variant

Default Variant

pub fn disabled(
  c: Chip(msg),
  interaction: types.Interaction,
) -> Chip(msg)

disabled sets the interaction field

pub fn filter(label: String) -> Chip(msg)

filter creates a basic Filter Chip

pub fn form(
  c: Chip(msg),
  form_submission: option.Option(form_submission.FormSubmission),
) -> Chip(msg)

form sets the form_submission field when the chip is used in a form

pub fn from_config(c: Config(msg)) -> Chip(msg)

from_config creates a Chip from a Config record

pub fn icon(c: Chip(msg), i: icon.Icon(msg)) -> Chip(msg)

icon sets the icon field

pub fn information(label: String) -> Chip(msg)

information creates a basic Information Chip

pub fn input(label: String) -> Chip(msg)

input creates a basic Input Chip

pub fn removable(
  c: Chip(msg),
  removability: Removability,
) -> Chip(msg)

removable sets the removability field

pub fn render(
  c: Chip(msg),
  attributes: List(attribute.Attribute(msg)),
  children: List(element.Element(msg)),
) -> element.Element(msg)

render creates a Lustre Element from a Chip

Parameters:

  • c: a Chip
  • attributes: any extra attributes, e.g. an event
  • 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(
  c: Chip(msg),
  selection: types.SelectionState,
) -> Chip(msg)

selected sets the selection field

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

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

pub fn suggestion(label: String) -> Chip(msg)

suggestion creates a basic Suggestion Chip

pub fn variant(c: Chip(msg), v: Variant) -> Chip(msg)

variant sets the variant field

Search Document