Plushie.Widget.PaneGrid (Plushie v0.7.2)

Copy Markdown View Source

Pane grid, resizable tiled panes.

Children are keyed by their node ID and rendered as individual panes. The renderer manages an internal pane_grid::State cache.

Accessibility

The pane grid itself does not expose a semantic role to assistive technology. To make the grid navigable by screen readers, wrap it in a container with an explicit role and label:

container "editor-panes" do
  a11y do
    role :group
    label "Editor panes"
  end

  pane_grid "grid", panes: ["left", "right"] do
    text_input "left", model.left
    text_input "right", model.right
  end
end

Individual panes can carry their own a11y annotations for further context (e.g., label describing each pane's purpose). The pane_focus_cycle event (F6/Shift+F6) provides keyboard navigation between panes.

Props

NameTypeDefaultDescription
panes[String.t() | atom()]nilList of pane identifiers.
spacingnumber()nilSpace between panes in pixels. Default: 2.
width:fill | :shrink | {:fill_portion, pos_integer()} | number()nilGrid width. Default: fill.
height:fill | :shrink | {:fill_portion, pos_integer()} | number()nilGrid height. Default: fill.
min_sizenumber()nilMinimum pane size in pixels. Default: 10.
divider_colorString.t()nilColor for the split divider.
divider_widthnumber()nilDivider thickness in pixels.
leewaynumber()nilGrabbable area around dividers in pixels.
split_axis:horizontal | :verticalnilSplit axis for initial layout.
event_rateinteger()nilMax events per second for coalescable events.
a11y%Plushie.Type.A11y{} | map() | keyword()%{role: :group}Accessibility annotations.

Events

EventTypeDescription
:pane_clickednoneEmitted when a pane is selected.
:pane_resizedvalue: %{split: String.t() | atom(), ratio: number()}Emitted when a split divider is moved.
:pane_draggednoneEmitted during pane drag operations.
:pane_focus_cyclenoneEmitted on F6/Shift+F6 focus cycling.

Summary

Functions

Accessibility annotations.

Converts this widget struct to a ui_node() map.

Color for the split divider.

Divider thickness in pixels.

Max events per second for coalescable events.

Appends multiple children to the widget.

Grid height. Default: fill.

Grabbable area around dividers in pixels.

Minimum pane size in pixels. Default: 10.

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

Creates a :pane_grid widget.

Sets the list of pane identifiers. Atoms are coerced to strings.

Appends a child to the widget.

Space between panes in pixels. Default: 2.

Split axis for initial layout.

Grid width. Default: fill.

Applies keyword options to an existing widget struct.

Types

option()

@type option() ::
  ((((((((({:panes, [String.t() | atom()]} | {:spacing, number()})
          | {:width,
             :fill | :shrink | {:fill_portion, pos_integer()} | number()})
         | {:height,
            :fill | :shrink | {:fill_portion, pos_integer()} | number()})
        | {:min_size, number()})
       | {:divider_color, atom() | String.t() | map()})
      | {:divider_width, number()})
     | {:leeway, number()})
    | {:split_axis, :horizontal | :vertical})
   | {: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.PaneGrid{
  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()],
  divider_color:
    String.t()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  divider_width:
    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,
  height:
    (:fill | :shrink | {:fill_portion, pos_integer()} | number())
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  id: String.t(),
  leeway:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  min_size:
    number()
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  panes:
    [String.t() | atom()]
    | 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,
  split_axis:
    (:horizontal | :vertical)
    | Plushie.Animation.Transition.t()
    | Plushie.Animation.Spring.t()
    | Plushie.Animation.Sequence.t()
    | nil,
  width:
    (:fill | :shrink | {:fill_portion, pos_integer()} | 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.

divider_color(widget, descriptor)

@spec divider_color(widget :: t(), value :: (atom() | String.t() | map()) | nil) ::
  t()

Color for the split divider.

Accepts String.t().

divider_width(widget, descriptor)

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

Divider thickness in pixels.

Accepts 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.

height(widget, descriptor)

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

Grid height. Default: fill.

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

leeway(widget, descriptor)

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

Grabbable area around dividers in pixels.

Accepts number().

min_size(widget, descriptor)

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

Minimum pane size in pixels. Default: 10.

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.

pane_grid(id, opts \\ [])

(macro)

Creates a :pane_grid widget.

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

import Plushie.Widget.PaneGrid, only: [pane_grid: 2]

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

panes(widget, descriptor)

@spec panes(widget :: t(), value :: [String.t() | atom()] | nil) :: t()

Sets the list of pane identifiers. Atoms are coerced to strings.

push(widget, child)

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

Appends a child to the widget.

spacing(widget, descriptor)

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

Space between panes in pixels. Default: 2.

Accepts number().

split_axis(widget, descriptor)

@spec split_axis(widget :: t(), value :: (:horizontal | :vertical) | nil) :: t()

Split axis for initial layout.

Accepts :horizontal | :vertical.

width(widget, descriptor)

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

Grid width. Default: fill.

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

with_options(widget, opts)

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

Applies keyword options to an existing widget struct.