Class: Railsboot::Navbar::NavComponent

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

Overview

ViewComponent: renders the nav block.

Instance Method Summary collapse

Constructor Details

#initialize(tag: "nav", **html_attributes) ⇒ NavComponent

Returns a new instance of NavComponent.

Parameters:

  • tag (String) (defaults to: "nav")

    the tag option

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes

  • :tag (String)

    HTML tag to render for the element



10
11
12
13
14
15
16
17
18
19
# File 'app/components/railsboot/navbar/nav_component.rb', line 10

def initialize(tag: "nav", **html_attributes)
  @tag = tag
  @html_attributes = html_attributes

  @html_attributes[:tag] = @tag
  @html_attributes[:class] = class_names(
    "navbar-nav",
    html_attributes.delete(:class)
  )
end