Class: Arara::DataTableComponent

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from BaseComponent

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

Constructor Details

#initialize(label: nil, **kw) ⇒ DataTableComponent

Returns a new instance of DataTableComponent.



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

def initialize(label: nil, **kw)
  super(tag: "div", **kw)
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



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

def label
  @label
end

Instance Method Details

#default_data_controllerObject



17
18
19
# File 'app/components/arara/data_table_component.rb', line 17

def default_data_controller
  "mdc-data-table"
end

#default_html_classObject



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

def default_html_class
  "mdc-data-table"
end

#table_optionsObject



25
26
27
28
29
30
31
32
33
34
# File 'app/components/arara/data_table_component.rb', line 25

def table_options
  opts = {
    class: "mdc-data-table__table"
  }
  unless label.empty?
    opts[:aria] ||= {}
    opts[:aria][:label] = label
  end
  opts
end

#table_tagObject



21
22
23
# File 'app/components/arara/data_table_component.rb', line 21

def table_tag
  "table"
end