Class: ElementComponent::Components::Table

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/table.rb

Constant Summary collapse

VALID_VARIANTS =
%i[primary secondary success danger warning info light dark].freeze

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(striped: false, bordered: false, hover: false, small: false, variant: nil, **attributes, &block) ⇒ Table

Returns a new instance of Table.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/element_component/components/table.rb', line 8

def initialize(striped: false, bordered: false, hover: false, small: false, variant: nil, **attributes, &block)
  super("table", &block)

  add_attribute(class: "table")
  add_attribute(class: "table-striped") if striped
  add_attribute(class: "table-bordered") if bordered
  add_attribute(class: "table-hover") if hover
  add_attribute(class: "table-sm") if small
  add_attribute(class: "table-#{variant}") if variant
  add_attribute(attributes) unless attributes.empty?
end