Macaw.Surface.Cell (macaw v0.1.2)

Copy Markdown View Source

A cell: one component placed in a surface (spec/06 §3.2).

  • component, the component's name as its package registers it, matched by spelling;
  • kind, the kind it renders as, :content by default;
  • settings, its settings by parameter name, inline, plain data;
  • slots, each slot bound to a source: %{source: name, fields: %{role => field}, params: %{name => value}}, a many role's fields a list;
  • place, where it sits in the grid: %{x, y, w, h} (spec/06 §3.3).

Names are strings; an atom is read as its spelling, and no atom is made from one.

Summary

Functions

A cell's keys, in order.

A cell from a keyword list or a map with atom keys: {:ok, cell} or every fault at once, by path from the cell.

Types

place()

@type place() :: %{
  x: non_neg_integer(),
  y: non_neg_integer(),
  w: pos_integer(),
  h: pos_integer()
}

slot()

@type slot() :: %{
  source: String.t(),
  fields: %{required(String.t()) => String.t() | [String.t()]},
  params: map()
}

t()

@type t() :: %Macaw.Surface.Cell{
  component: String.t(),
  kind: Macaw.Component.kind(),
  place: place() | nil,
  settings: %{required(String.t()) => term()},
  slots: %{required(String.t()) => slot()}
}

Functions

keys()

@spec keys() :: [atom(), ...]

A cell's keys, in order.

new(attrs)

@spec new(keyword() | map()) :: {:ok, t()} | {:error, [Macaw.Layers.Fault.t(), ...]}

A cell from a keyword list or a map with atom keys: {:ok, cell} or every fault at once, by path from the cell.