Class: GovukComponent::ServiceNavigationComponent::NavigationItemComponent
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::ServiceNavigationComponent::NavigationItemComponent
- Defined in:
- app/components/govuk_component/service_navigation_component/navigation_item_component.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#active_when ⇒ Object
readonly
Returns the value of attribute active_when.
-
#current ⇒ Object
readonly
Returns the value of attribute current.
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
#href ⇒ Object
readonly
Returns the value of attribute href.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text:, href: nil, current_path: nil, active_when: nil, current: false, active: false, classes: [], html_attributes: {}) ⇒ NavigationItemComponent
constructor
A new instance of NavigationItemComponent.
Methods inherited from Base
Constructor Details
#initialize(text:, href: nil, current_path: nil, active_when: nil, current: false, active: false, classes: [], html_attributes: {}) ⇒ NavigationItemComponent
Returns a new instance of NavigationItemComponent.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 4 def initialize(text:, href: nil, current_path: nil, active_when: nil, current: false, active: false, classes: [], html_attributes: {}) @current = current @active = active @text = text @href = href @current_path = current_path @active_when = active_when super(classes:, html_attributes:) end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def active @active end |
#active_when ⇒ Object (readonly)
Returns the value of attribute active_when.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def active_when @active_when end |
#current ⇒ Object (readonly)
Returns the value of attribute current.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def current @current end |
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def current_path @current_path end |
#href ⇒ Object (readonly)
Returns the value of attribute href.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def href @href end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
2 3 4 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 2 def text @text end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/components/govuk_component/service_navigation_component/navigation_item_component.rb', line 16 def call tag.li(**html_attributes) do if href.present? wrap_link(link_to(text, href, class: "#{brand}-service-navigation__link", **aria_current)) else tag.span(text, class: "#{brand}-service-navigation__text") end end end |