Class: Railsboot::NavbarComponent

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

Constant Summary collapse

EXPANDS =
["sm", "md", "lg", "xl", "xxl"].freeze
DEFAULT_EXPAND =
"".freeze

Constants inherited from Component

Component::COLORS, Component::DEFAULT_COLOR

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of NavbarComponent.



5
6
7
8
9
10
11
12
13
14
# File 'app/components/railsboot/navbar_component.rb', line 5

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