Class: Railsboot::ButtonGroupComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/button_group_component.rb

Constant Summary collapse

SIZES =
["", "lg", "sm"].freeze
DEFAULT_SIZE =
"".freeze

Constants inherited from Component

Component::COLORS, Component::DEFAULT_COLOR

Instance Method Summary collapse

Constructor Details

#initialize(aria_label: "", size: DEFAULT_SIZE, **html_attributes) ⇒ ButtonGroupComponent

Returns a new instance of ButtonGroupComponent.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'app/components/railsboot/button_group_component.rb', line 5

def initialize(aria_label: "", size: DEFAULT_SIZE, **html_attributes)
  @aria_label = aria_label
  @size = fetch_or_fallback(size, SIZES, DEFAULT_SIZE)
  @html_attributes = html_attributes

  @html_attributes[:tag] = "div"
  @html_attributes[:class] = class_names(
    "btn-group",
    {"btn-group-#{@size}" => @size.present?},
    html_attributes.delete(:class)
  )
end