Class: ActiveElement::Components::Navbar

Inherits:
Object
  • Object
show all
Includes:
Translations
Defined in:
lib/active_element/components/navbar.rb

Overview

A navigation bar providing links to areas within the application.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Translations

#i18n, #model

Constructor Details

#initialize(controller, items: nil, fixed: true) ⇒ Navbar

Returns a new instance of Navbar.



11
12
13
14
15
# File 'lib/active_element/components/navbar.rb', line 11

def initialize(controller, items: nil, fixed: true)
  @controller = controller
  @items = items
  @fixed = fixed
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



9
10
11
# File 'lib/active_element/components/navbar.rb', line 9

def controller
  @controller
end

Instance Method Details

#active_path_class(current_navbar_item:) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/active_element/components/navbar.rb', line 29

def active_path_class(current_navbar_item:)
  if ActiveMenuLink.new(
    rails_component: RailsComponent.new(Rails),
    navbar_items: items,
    current_path: controller.request.path,
    current_navbar_item: current_navbar_item,
    controller_path: controller.controller_path,
    action_name: controller.action_name
  ).active?
    'active'
  end
end

#localsObject



21
22
23
24
25
26
27
# File 'lib/active_element/components/navbar.rb', line 21

def locals
  {
    component: self,
    items: items,
    fixed: fixed
  }
end

#templateObject



17
18
19
# File 'lib/active_element/components/navbar.rb', line 17

def template
  'active_element/components/navbar'
end