Plushie.Table.Element (Plushie v0.7.2)

Copy Markdown View Source

Behaviour for table structural elements.

Table elements are the building blocks of table composition. Like canvas elements, they produce tree nodes with typed fields, but they operate in the table domain: rows and cells within a table widget, rendered by the table renderer.

Declaring an element

defmodule Plushie.Table.Row do
  use Plushie.Table.Element

  element :table_row, container: true do
  end
end

Generated code

The macro generates the same code as Plushie.Canvas.Element:

  • new/1 auto-ID constructor
  • new/2 constructor with explicit ID
  • Setter functions per field
  • push/2 and extend/2 for container elements
  • build/1 for ui_node() conversion
  • Plushie.Tree.Node protocol implementation

Uses the same Plushie.DSL.Element infrastructure as canvas elements. The separate module provides domain-appropriate naming.