Class: Bs5::ButtonGroupComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/bs5/button_group_component.rb

Constant Summary collapse

SIZES =
{ small: :sm, large: :lg }.with_indifferent_access.freeze
CLASS_PREFIX =
'btn-group'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ ButtonGroupComponent

Returns a new instance of ButtonGroupComponent.



10
11
12
13
14
# File 'app/components/bs5/button_group_component.rb', line 10

def initialize(options = {})
  @options = options.symbolize_keys
  @vertical = @options.delete(:vertical)
  @size = @options.delete(:size)
end

Instance Attribute Details

#sizeObject (readonly)

Returns the value of attribute size.



8
9
10
# File 'app/components/bs5/button_group_component.rb', line 8

def size
  @size
end

#verticalObject (readonly)

Returns the value of attribute vertical.



8
9
10
# File 'app/components/bs5/button_group_component.rb', line 8

def vertical
  @vertical
end

Instance Method Details

#component_attributesObject



20
21
22
23
24
# File 'app/components/bs5/button_group_component.rb', line 20

def component_attributes
  default_options = { role: 'group' }
  @options[:class] = component_class
  @options.merge(default_options)
end

#render?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/components/bs5/button_group_component.rb', line 16

def render?
  content.present?
end