Class: Docks::Themes::API::Components::Table
- Inherits:
-
Base
- Object
- Base
- Docks::Themes::API::Components::Table
show all
- Defined in:
- lib/docks_theme_api/components/table_component.rb
Instance Attribute Summary
Attributes inherited from Base
#block
Instance Method Summary
collapse
Methods inherited from Base
#==, #classes_for, #config, #inspect, #method_missing, #respond_to?, #to_s
Constructor Details
#initialize(*args) ⇒ Table
Returns a new instance of Table.
7
8
9
10
|
# File 'lib/docks_theme_api/components/table_component.rb', line 7
def initialize(*args)
@cell_element = "td"
super
end
|
Instance Method Details
#body(&block) ⇒ Object
18
19
20
|
# File 'lib/docks_theme_api/components/table_component.rb', line 18
def body(&block)
concat "<tbody class='table__body'>#{capture(&block)}</tbody>"
end
|
#cell(content, options = {}) ⇒ Object
26
27
28
29
30
|
# File 'lib/docks_theme_api/components/table_component.rb', line 26
def cell(content, options = {})
klass = "table__cell"
klass << " table__cell--centered" if options.fetch(:centered?, false)
"<#{@cell_element} class='#{klass}'>#{content}</#{@cell_element}>"
end
|
12
13
14
15
16
|
# File 'lib/docks_theme_api/components/table_component.rb', line 12
def (&block)
old_cell_element, @cell_element = @cell_element, "th"
concat "<thead class='table__header'>#{capture(&block)}</thead>"
@cell_element = old_cell_element
end
|
#row(&block) ⇒ Object
22
23
24
|
# File 'lib/docks_theme_api/components/table_component.rb', line 22
def row(&block)
concat "<tr class='table__row'>#{capture(&block)}</tr>"
end
|