Class: Railsboot::Nav::ItemComponent

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

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.



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

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



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

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