class AppHeaderNavigationItemComponent
Public Class Methods
Source
# File app/components/app_header_navigation_item_component.rb, line 4 def initialize(title, path, request_path:, count: nil) @title = title @path = path @request_path = request_path @count = count end
Public Instance Methods
Source
# File app/components/app_header_navigation_item_component.rb, line 11 def call tag.li(class: classes) do link_to( @path, class: "nhsuk-header__navigation-link", aria: { current: current? ? "page" : nil } ) { safe_join([@title, count_tag].compact) } end end
Source
# File app/components/app_header_navigation_item_component.rb, line 27 def classes [ "nhsuk-header__navigation-item", ("nhsuk-header__navigation-item--current" if current?), ("app-header__navigation-item--with-count" if show_count?) ].compact.join(" ") end
Source
# File app/components/app_header_navigation_item_component.rb, line 39 def count_tag render AppCountComponent.new(@count) if show_count? end
Source
# File app/components/app_header_navigation_item_component.rb, line 23 def current? @request_path.starts_with?(@path) end
Source
# File app/components/app_header_navigation_item_component.rb, line 35 def show_count? @count != nil end