Class: Arara::DataTableBodyRowComponent

Inherits:
ActionView::Component::Base
  • Object
show all
Includes:
BaseComponent
Defined in:
app/components/arara/data_table_body_row_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

#default_data_controller, #default_html_tag, #html_class, #html_content, #html_data, #html_tag, included

Constructor Details

#initialize(selected: false, **kw) ⇒ DataTableBodyRowComponent

Returns a new instance of DataTableBodyRowComponent.



8
9
10
11
# File 'app/components/arara/data_table_body_row_component.rb', line 8

def initialize(selected: false, **kw)
  super(tag: "tr", **kw)
  @selected = selected
end

Instance Attribute Details

#selectedObject (readonly)

Returns the value of attribute selected.



4
5
6
# File 'app/components/arara/data_table_body_row_component.rb', line 4

def selected
  @selected
end

Instance Method Details

#default_html_classObject



13
14
15
16
# File 'app/components/arara/data_table_body_row_component.rb', line 13

def default_html_class
  return "mdc-data-table__row mdc-data-table__row--selected" if selected
  "mdc-data-table__row"
end

#html_optionsObject



18
19
20
21
22
23
24
25
# File 'app/components/arara/data_table_body_row_component.rb', line 18

def html_options
  opts = super
  if selected
    opts[:aria] = {} unless opts.has_key?(:aria)
    opts[:aria][:selected] = true
  end
  opts
end