Plushie.Widget.Grid (Plushie v0.7.2)

Copy Markdown View Source

Grid layout, arranges children in a fixed-column grid.

Props

NameTypeDefaultDescription
num_columnsinteger()nilNumber of columns. Default: 1.
spacingnumber()nilSpacing between grid cells in pixels. Default: 0.
widthnumber()nilGrid width in pixels.
heightnumber()nilGrid height in pixels.
column_width:fill | :shrink | {:fill_portion, pos_integer()} | number()nilWidth of each column. Accepts :fill, :shrink, {:fill_portion, n}, or a number.
row_height:fill | :shrink | {:fill_portion, pos_integer()} | number()nilHeight of each row. Accepts :fill, :shrink, {:fill_portion, n}, or a number.
fluidnumber()nilEnables fluid grid mode. Value is max cell width; columns auto-wrap.
event_rateinteger()nilMax events per second for coalescable events.
a11y%Plushie.Type.A11y{} | map() | keyword()nilAccessibility annotations.

Summary

Functions

Accessibility annotations.

Converts this widget struct to a ui_node() map.

Width of each column. Accepts :fill, :shrink, {:fill_portion, n}, or a number.

Max events per second for coalescable events.

Appends multiple children to the widget.

Enables fluid grid mode. Value is max cell width; columns auto-wrap.

Creates a :grid widget.

Grid height in pixels.

Creates a new widget struct with the given ID and keyword options.

Number of columns. Default: 1.

Appends a child to the widget.

Height of each row. Accepts :fill, :shrink, {:fill_portion, n}, or a number.

Spacing between grid cells in pixels. Default: 0.

Grid width in pixels.

Applies keyword options to an existing widget struct.

Types

option()

@type option() ::
  ((((((({:num_columns, integer()} | {:spacing, number()}) | {:width, number()})
       | {:height, number()})
      | {:column_width,
         :fill | :shrink | {:fill_portion, pos_integer()} | number()})
     | {:row_height,
        :fill | :shrink | {:fill_portion, pos_integer()} | number()})
    | {:fluid, number()})
   | {:event_rate, integer()})
  | {:a11y,
     %Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword()}

t()

@type t() :: %Plushie.Widget.Grid{
  a11y:
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  children: [Plushie.Widget.ui_node()],
  column_width:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  event_rate:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  fluid:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  height:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  num_columns:
    integer()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  row_height:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  spacing:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  width:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil
}

Functions

a11y(widget, descriptor)

@spec a11y(
  widget :: t(),
  value ::
    (%Plushie.Type.A11y{
       active_descendant: term(),
       busy: term(),
       described_by: term(),
       description: term(),
       disabled: term(),
       error_message: term(),
       expanded: term(),
       has_popup: term(),
       hidden: term(),
       invalid: term(),
       label: term(),
       label_from: term(),
       labelled_by: term(),
       level: term(),
       live: term(),
       mnemonic: term(),
       modal: term(),
       orientation: term(),
       position_in_set: term(),
       radio_group: term(),
       read_only: term(),
       required: term(),
       role: term(),
       selected: term(),
       size_of_set: term(),
       toggled: term(),
       value: term()
     }
     | map()
     | keyword())
    | nil
) :: t()

Accessibility annotations.

Accepts %Plushie.Type.A11y{} | map() | keyword().

build(widget)

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

Converts this widget struct to a ui_node() map.

column_width(widget, descriptor)

@spec column_width(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) :: t()

Width of each column. Accepts :fill, :shrink, {:fill_portion, n}, or a number.

Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().

event_rate(widget, descriptor)

@spec event_rate(widget :: t(), value :: integer() | nil) :: t()

Max events per second for coalescable events.

Accepts integer().

extend(widget, children)

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

Appends multiple children to the widget.

fluid(widget, descriptor)

@spec fluid(widget :: t(), value :: number() | nil) :: t()

Enables fluid grid mode. Value is max cell width; columns auto-wrap.

Accepts number().

grid(id, opts \\ [])

(macro)

Creates a :grid widget.

Shorthand for new/2. Import this macro to use the widget name directly in view functions:

import Plushie.Widget.Grid, only: [grid: 2]

grid("my-id", prop: value)

height(widget, descriptor)

@spec height(widget :: t(), value :: number() | nil) :: t()

Grid height in pixels.

Accepts number().

new(id, opts \\ [])

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

Creates a new widget struct with the given ID and keyword options.

num_columns(widget, descriptor)

@spec num_columns(widget :: t(), value :: integer() | nil) :: t()

Number of columns. Default: 1.

Accepts integer().

push(widget, child)

@spec push(widget :: t(), child :: Plushie.Widget.child()) :: t()

Appends a child to the widget.

row_height(widget, descriptor)

@spec row_height(
  widget :: t(),
  value :: (:fill | :shrink | {:fill_portion, pos_integer()} | number()) | nil
) :: t()

Height of each row. Accepts :fill, :shrink, {:fill_portion, n}, or a number.

Accepts :fill | :shrink | {:fill_portion, pos_integer()} | number().

spacing(widget, descriptor)

@spec spacing(widget :: t(), value :: number() | nil) :: t()

Spacing between grid cells in pixels. Default: 0.

Accepts number().

width(widget, descriptor)

@spec width(widget :: t(), value :: number() | nil) :: t()

Grid width in pixels.

Accepts number().

with_options(widget, opts)

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

Applies keyword options to an existing widget struct.