Class: ElementComponent::Components::ButtonGroup

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

Constant Summary collapse

VALID_SIZES =
%i[sm lg].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(size: nil, vertical: false, **attributes, &block) ⇒ ButtonGroup

Returns a new instance of ButtonGroup.



8
9
10
11
12
13
14
15
# File 'lib/element_component/components/button_group.rb', line 8

def initialize(size: nil, vertical: false, **attributes, &block)
  super("div", &block)

  add_attribute(class: vertical ? "btn-group-vertical" : "btn-group")
  add_attribute(class: "btn-group-#{size}") if size
  add_attribute(role: "group")
  add_attribute(attributes) unless attributes.empty?
end