Class: MojComponent::HeaderComponent::NavigationItem

Inherits:
ApplicationComponent show all
Defined in:
app/components/moj_component/header_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, href: nil, current: nil, options: {}) ⇒ NavigationItem

Returns a new instance of NavigationItem.



22
23
24
25
26
27
28
# File 'app/components/moj_component/header_component.rb', line 22

def initialize(text:, href: nil, current: nil, options: {})
  @text = text
  @href = href
  @current = current
  @options = options
  super()
end

Instance Attribute Details

#currentObject (readonly)

Returns the value of attribute current.



20
21
22
# File 'app/components/moj_component/header_component.rb', line 20

def current
  @current
end

#hrefObject (readonly)

Returns the value of attribute href.



20
21
22
# File 'app/components/moj_component/header_component.rb', line 20

def href
  @href
end

#optionsObject (readonly)

Returns the value of attribute options.



20
21
22
# File 'app/components/moj_component/header_component.rb', line 20

def options
  @options
end

#textObject (readonly)

Returns the value of attribute text.



20
21
22
# File 'app/components/moj_component/header_component.rb', line 20

def text
  @text
end

Instance Method Details

#callObject



30
31
32
33
34
# File 'app/components/moj_component/header_component.rb', line 30

def call
  tag.li class: "moj-header__navigation-item" do
    link_to(text, href, class: "moj-header__navigation-link", aria: current_override, **options)
  end
end