Class: Railsboot::ListGroup::ItemComponent

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

Instance Method Summary collapse

Constructor Details

#initialize(tag: "li", active: false, disabled: false, color: nil, **html_attributes) ⇒ ItemComponent

Returns a new instance of ItemComponent.



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'app/components/railsboot/list_group/item_component.rb', line 2

def initialize(tag: "li", active: false, disabled: false, color: nil, **html_attributes)
  @tag = tag
  @active = active
  @disabled = disabled
  @color = fetch_or_fallback(color, COLORS, "")
  @html_attributes = html_attributes

  @html_attributes[:tag] = @tag
  @html_attributes[:class] = class_names(
    "list-group-item",
    {"list-group-item-#{color}" => @color.present?},
    {"active" => @active},
    {"disabled" => @disabled},
    html_attributes.delete(:class)
  )
end

Instance Method Details

#callObject



19
20
21
# File 'app/components/railsboot/list_group/item_component.rb', line 19

def call
  render(Railsboot::BaseComponent.new(tag: "li", **@html_attributes)) { content }
end