Class: Railsboot::Nav::ItemComponent

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

Overview

ViewComponent: renders the item block.

Instance Method Summary collapse

Constructor Details

#initialize(text: "", href: "", active: false, disabled: false, wrapper_item: false, wrapper_tag: "li", wrapper_html_attributes: {}, **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
20
21
# File 'app/components/railsboot/nav/item_component.rb', line 4

def initialize(text: "", href: "", active: false, disabled: false, wrapper_item: false, wrapper_tag: "li", wrapper_html_attributes: {}, **html_attributes)
  @text = text
  @href = href
  @active = active
  @disabled = disabled
  @html_attributes = html_attributes

  @wrapper_item = wrapper_item
  @wrapper_tag = wrapper_tag
  @wrapper_html_attributes = wrapper_html_attributes

  @html_attributes[:class] = class_names(
    "nav-link",
    { "active" => @active },
    { "disabled" => @disabled },
    html_attributes.delete(:class)
  )
end

Instance Method Details

#adjusted_wrapper_html_attributesObject



23
24
25
26
# File 'app/components/railsboot/nav/item_component.rb', line 23

def adjusted_wrapper_html_attributes
  @wrapper_html_attributes["class"] = ["nav-item", @wrapper_html_attributes.delete(:class)].compact_blank.uniq.join(" ")
  @wrapper_html_attributes
end