Class: PhlexKit::DataTableExpandToggle

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/phlex_kit/data_table/data_table_expand_toggle.rb

Overview

Chevron button toggling a row-detail element (pass its id as controls:); the chevron rotates via [aria-expanded] CSS. See data_table.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(controls:, expanded: false, label: "Toggle row details", **attrs) ⇒ DataTableExpandToggle

Returns a new instance of DataTableExpandToggle.



5
6
7
8
9
10
# File 'app/components/phlex_kit/data_table/data_table_expand_toggle.rb', line 5

def initialize(controls:, expanded: false, label: "Toggle row details", **attrs)
  @controls = controls
  @expanded = expanded
  @label = label
  @attrs = attrs
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/data_table/data_table_expand_toggle.rb', line 12

def view_template
  button(**mix({
    type: :button,
    class: "pk-data-table-expand-toggle",
    aria: { expanded: @expanded.to_s, controls: @controls, label: @label },
    data: { action: "click->phlex-kit--data-table#toggleRowDetail" }
  }, @attrs)) do
    icon
  end
end