Class: DocsUI::PropTable

Inherits:
Phlex::HTML
  • Object
show all
Defined in:
app/components/docs_ui/prop_table.rb

Overview

A props/options/params reference table: name · type · default · description, with the first column (the name) auto code-styled. A thin preset over DocsUI::Table — same cell conventions, same markup, no duplication.

render DocsUI::PropTable.new(
[
  ["brand", "String", '"Docs"', "Topbar + sidebar heading."],
  ["themes", "Array", "%w[dark light]", "ThemeSwitcher options."],
]
)

The default headers are Option/Type/Default/Description; pass headers: to override (e.g. %w[Arg Type Default Description] for a component's args). Cell values follow DocsUI::Table's convention (String / [:code, "x"] / [:md, "…"]); the first cell of each row is wrapped in automatically unless it's already a special-cell pair.

Constant Summary collapse

DEFAULT_HEADERS =
%w[Option Type Default Description].freeze

Instance Method Summary collapse

Constructor Details

#initialize(rows, headers: DEFAULT_HEADERS) ⇒ PropTable

Returns a new instance of PropTable.



23
24
25
26
# File 'app/components/docs_ui/prop_table.rb', line 23

def initialize(rows, headers: DEFAULT_HEADERS)
  @rows = rows.map { |cells| code_first_column(cells) }
  @headers = headers
end

Instance Method Details

#view_templateObject



28
29
30
# File 'app/components/docs_ui/prop_table.rb', line 28

def view_template
  render DocsUI::Table.new(@headers, @rows)
end