Class: Railsboot::ListGroup::ItemComponent

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

Overview

ViewComponent: renders the item block.

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ItemComponent.



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

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



21
22
23
# File 'app/components/railsboot/list_group/item_component.rb', line 21

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