Plushie.Widget.Responsive (Plushie v0.6.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 %WidgetEvent{type: :resize, id: id, data: %{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 Plushie.Type.Length.
  • height (length) -- container height. Default: fill.
  • a11y (map) -- accessibility overrides. See Plushie.Type.A11y.

Summary

Functions

Sets accessibility annotations.

Converts this responsive struct to a ui_node() map via the Plushie.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, Plushie.Type.Length.t()}
  | {:height, Plushie.Type.Length.t()}
  | {:a11y, Plushie.Type.A11y.t() | map() | keyword()}

t()

@type t() :: %Plushie.Widget.Responsive{
  a11y: Plushie.Type.A11y.t() | nil,
  children: [Plushie.Widget.child()],
  height: Plushie.Type.Length.t() | nil,
  id: String.t(),
  width: Plushie.Type.Length.t() | nil
}

Functions

a11y(r, a11y)

@spec a11y(responsive :: t(), a11y :: Plushie.Type.A11y.t() | map() | keyword()) ::
  t()

Sets accessibility annotations.

build(r)

@spec build(responsive :: t()) :: Plushie.Widget.ui_node()

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

extend(r, children)

@spec extend(
  responsive :: t(),
  children :: [Plushie.Widget.child()]
) :: t()

Appends multiple children to the responsive container.

height(r, height)

@spec height(responsive :: t(), height :: Plushie.Type.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 :: Plushie.Widget.child()) :: t()

Appends a child to the responsive container.

width(r, width)

@spec width(responsive :: t(), width :: Plushie.Type.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.