Class: Railsboot::Navbar::TogglerComponent

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

Overview

ViewComponent: renders the toggler block.

Instance Method Summary collapse

Constructor Details

#initialize(id:, **html_attributes) ⇒ TogglerComponent

Returns a new instance of TogglerComponent.

Parameters:

  • id (String)

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



7
8
9
10
11
12
13
14
15
# File 'app/components/railsboot/navbar/toggler_component.rb', line 7

def initialize(id:, **html_attributes)
  @id = id
  @html_attributes = html_attributes

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