Class: RubyUI::DataTableExpandToggle

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_ui/data_table/data_table_expand_toggle.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Attribute Summary

Attributes inherited from Base

#attrs

Instance Method Summary collapse

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 'lib/ruby_ui/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
  super(**attrs)
end

Instance Method Details

#view_templateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_ui/data_table/data_table_expand_toggle.rb', line 12

def view_template
  button(
    type: "button",
    aria_expanded: @expanded.to_s,
    aria_controls: @controls,
    aria_label: @label,
    data: {
      action: "click->ruby-ui--data-table#toggleRowDetail"
    },
    **attrs
  ) do
    render_icon
  end
end