Search documentation of Plushie

# 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

Name | Type | Default | Description
--- | --- | --- | ---
`panes` | `[String.t() | atom()]` | `nil` | List of pane identifiers.
`spacing` | `number()` | `nil` | Space between panes in pixels. Default: 2.
`width` | `:fill | :shrink | {:fill_portion, pos_integer()} | number()` | `nil` | Grid width. Default: fill.
`height` | `:fill | :shrink | {:fill_portion, pos_integer()} | number()` | `nil` | Grid height. Default: fill.
`min_size` | `number()` | `nil` | Minimum pane size in pixels. Default: 10.
`divider_color` | `String.t()` | `nil` | Color for the split divider.
`divider_width` | `number()` | `nil` | Divider thickness in pixels.
`leeway` | `number()` | `nil` | Grabbable area around dividers in pixels.
`split_axis` | `:horizontal | :vertical` | `nil` | Split axis for initial layout.
`event_rate` | `integer()` | `nil` | Max events per second for coalescable events.
`a11y` | `%Plushie.Type.A11y{} | map() | keyword()` | `%{role: :group}` | Accessibility annotations.

## Events

Event | Type | Description
--- | --- | ---
`:pane_clicked` | none | Emitted when a pane is selected.
`:pane_resized` | `value: %{split: String.t() | atom(), ratio: number()}` | Emitted when a split divider is moved.
`:pane_dragged` | none | Emitted during pane drag operations.
`:pane_focus_cycle` | none | Emitted on F6/Shift+F6 focus cycling.

## Summary

### Types

option()
t()

### Functions

a11y(widget, descriptor)

Accessibility annotations.

build(widget)

Converts this widget struct to a `ui_node()` map.

divider_color(widget, descriptor)

Color for the split divider.

divider_width(widget, descriptor)

Divider thickness in pixels.

event_rate(widget, descriptor)

Max events per second for coalescable events.

extend(widget, children)

Appends multiple children to the widget.

height(widget, descriptor)

Grid height. Default: fill.

leeway(widget, descriptor)

Grabbable area around dividers in pixels.

min_size(widget, descriptor)

Minimum pane size in pixels. Default: 10.

new(id, opts \\ [])

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

pane_grid(id, opts \\ [])

Creates a `:pane_grid` widget.

panes(widget, descriptor)

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

push(widget, child)

Appends a child to the widget.

spacing(widget, descriptor)

Space between panes in pixels. Default: 2.

split_axis(widget, descriptor)

Split axis for initial layout.

width(widget, descriptor)

Grid width. Default: fill.

with_options(widget, opts)

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.