m3e/icon

icon provides Lustre support for the M3E Icon component

Types

Config holds the configuration for an Icon

pub type Config(msg) {
  Config(
    name: String,
    fill: Fill,
    grade: Grade,
    optical_size: Int,
    purpose: attribute.Attribute(msg),
    variant: Variant,
    weight: Int,
  )
}

Constructors

Fill specifies if the icon is filled or not

pub type Fill {
  Filled
  NotFilled
}

Constructors

  • Filled
  • NotFilled

The Grade of the variable font icon Refer

pub type Grade {
  Low
  Medium
  High
}

Constructors

  • Low
  • Medium
  • High

Icon is the basis for a m3e-icon element that uses Material Symbols

Fields:

  • name: The icon to load, Refer to Material Symbols
  • fill: is the icon filled or not (the FILL axis of the variable font)
  • grade: the stroke thickness of an icon (the GRAD axis of the variable font)
  • optical_size: the optical size of the icon. Between 20 and 48
  • purpose: the role of the icon
  • variant: the visual style of the icon
  • weight: the thickness and boldness of the icon’s strokes. Between 100 and 700
pub opaque type Icon(msg)

The Optical Size of the variable font icon Refer

pub type OpticalSize =
  Int

The Variant of the icon

pub type Variant {
  Outlined
  Rounded
  Sharp
}

Constructors

  • Outlined
  • Rounded
  • Sharp

The Weight of the variable font icon Refer

pub type Weight =
  Int

Values

pub fn default_config() -> Config(msg)

default_config creates a new Config with default values

pub const default_fill: Fill
pub const default_grade: Grade

Default grade

pub const default_optical_size: Int

The default optical size of the icon

pub const default_variant: Variant

Default variant

pub const default_weight: Int

The default weight of the icon

pub fn filled(i: Icon(msg), fill: Fill) -> Icon(msg)

filled sets the fill field

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

from_config creates an Icon from a Config record

pub fn grade(i: Icon(msg), g: Grade) -> Icon(msg)

grade sets the grade field

pub const largest_optical_size: Int

The largest optical size

pub const largest_weight: Int

The largest weight of the icon

pub fn new(name: String) -> Icon(msg)

new constructs an Icon for the named Material Symbol. All fields are set to defaults

Parameters:

  • name: the name of the Material Symbol used in this Icon
pub fn optical_size(i: Icon(msg), os: Int) -> Icon(msg)

optical_size checks and then sets the optical_size field

pub fn purpose(
  i: Icon(msg),
  p: attribute.Attribute(msg),
) -> Icon(msg)

purpose sets the purpose field

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

render creates an m3e-icon Lustre custom element from an Icon

Parameters:

  • i: the Icon on which the element is based
  • attributes: additional HTML attributes
  • children: child HTML 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 const smallest_optical_size: Int

The smallest optical size of the icon

pub const smallest_weight: Int

The smallest weight of the icon

pub fn variant(i: Icon(msg), v: Variant) -> Icon(msg)

variant sets the variant field

pub fn weight(i: Icon(msg), w: Int) -> Icon(msg)

weight sets the weight field

Search Document