Class: Railsboot::NavbarComponent

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

Overview

ViewComponent: renders the navbar block.

Constant Summary collapse

EXPANDS =

Expands.

%w[sm md lg xl xxl].freeze
DEFAULT_EXPAND =

Default expand.

"".freeze

Instance Method Summary collapse

Constructor Details

#initialize(expand: DEFAULT_EXPAND, **html_attributes) ⇒ NavbarComponent

Returns a new instance of NavbarComponent.

Parameters:

  • expand (String) (defaults to: DEFAULT_EXPAND)

    the expand 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



12
13
14
15
16
17
18
19
20
21
# File 'app/components/railsboot/navbar_component.rb', line 12

def initialize(expand: DEFAULT_EXPAND, **html_attributes)
  @expand = fetch_or_fallback(expand, EXPANDS, DEFAULT_EXPAND)
  @html_attributes = html_attributes

  @html_attributes[:class] = class_names(
    "navbar",
    { "navbar-expand-#{@expand}" => @expand.present? },
    html_attributes.delete(:class)
  )
end