Class: GovukComponent::ServiceNavigationComponent
- Defined in:
- app/components/govuk_component/service_navigation_component.rb
Defined Under Namespace
Classes: NavigationItemComponent, ServiceNameComponent
Instance Attribute Summary collapse
-
#aria_label_text ⇒ Object
readonly
Returns the value of attribute aria_label_text.
-
#navigation_id ⇒ Object
readonly
Returns the value of attribute navigation_id.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', classes: [], html_attributes: {}) ⇒ ServiceNavigationComponent
constructor
A new instance of ServiceNavigationComponent.
- #navigation ⇒ Object
- #navigation_list ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', classes: [], html_attributes: {}) ⇒ ServiceNavigationComponent
Returns a new instance of ServiceNavigationComponent.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 21 def initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', classes: [], html_attributes: {}) @service_name_text = service_name @service_url = service_url @current_path = current_path @aria_label_text = aria_label @navigation_id = if @service_name_text.present? with_service_name(service_name: @service_name_text, service_url:) end .each { |ni| (current_path:, **ni) } super(classes:, html_attributes:) end |
Instance Attribute Details
#aria_label_text ⇒ Object (readonly)
Returns the value of attribute aria_label_text.
19 20 21 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 19 def aria_label_text @aria_label_text end |
#navigation_id ⇒ Object (readonly)
Returns the value of attribute navigation_id.
19 20 21 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 19 def @navigation_id end |
Instance Method Details
#call ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 37 def call outer_element do tag.div(class: "#{brand}-width-container") do safe_join( [ start_slot, tag.div(class: "#{brand}-service-navigation__container") do safe_join([service_name, ].compact) end, end_slot ] ) end end end |
#navigation ⇒ Object
53 54 55 56 57 58 59 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 53 def return unless tag.nav(aria: { label: "Menu" }, class: "#{brand}-service-navigation__wrapper") do safe_join([, ]) end end |
#navigation_list ⇒ Object
61 62 63 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 61 def tag.ul(safe_join(), id: , class: "#{brand}-service-navigation__list") end |