Toddy.Iced.Widget.Responsive (Toddy v0.3.0)

Copy Markdown View Source

Responsive layout -- adapts to available size by reporting resize events.

The renderer wraps child content in a sensor that sends %Sensor{type: :resize, id: id, width: w, height: h} events so the Elixir app can adjust its view based on the measured size.

Props

  • width (length) -- container width. Default: fill. See Toddy.Iced.Length.
  • height (length) -- container height. Default: fill.
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Summary

Functions

Sets accessibility annotations.

Converts this responsive struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Appends multiple children to the responsive container.

Sets the container height.

Creates a new responsive struct with optional keyword opts.

Appends a child to the responsive container.

Sets the container width.

Applies keyword options to an existing responsive struct.

Types

option()

@type option() ::
  {:width, Toddy.Iced.Length.t()}
  | {:height, Toddy.Iced.Length.t()}
  | {:a11y, Toddy.Iced.A11y.t()}

t()

@type t() :: %Toddy.Iced.Widget.Responsive{
  a11y: Toddy.Iced.A11y.t() | nil,
  children: [Toddy.Iced.ui_node() | struct()],
  height: Toddy.Iced.Length.t() | nil,
  id: String.t(),
  width: Toddy.Iced.Length.t() | nil
}

Functions

a11y(r, a11y)

@spec a11y(responsive :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

build(r)

@spec build(responsive :: t()) :: Toddy.Iced.ui_node()

Converts this responsive struct to a ui_node() map via the Toddy.Iced.Widget protocol.

extend(r, children)

@spec extend(responsive :: t(), children :: [Toddy.Iced.ui_node() | struct()]) :: t()

Appends multiple children to the responsive container.

height(r, height)

@spec height(responsive :: t(), height :: Toddy.Iced.Length.t()) :: t()

Sets the container height.

new(id, opts \\ [])

@spec new(id :: String.t(), opts :: [option()]) :: t()

Creates a new responsive struct with optional keyword opts.

push(r, child)

@spec push(responsive :: t(), child :: Toddy.Iced.ui_node() | struct()) :: t()

Appends a child to the responsive container.

width(r, width)

@spec width(responsive :: t(), width :: Toddy.Iced.Length.t()) :: t()

Sets the container width.

with_options(r, opts)

@spec with_options(responsive :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing responsive struct.