Class: GovukComponent::ServiceNavigationComponent
- Inherits:
-
Base
- Object
- Base
- 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.
-
#inline ⇒ Object
readonly
Returns the value of attribute inline.
-
#inverse ⇒ Object
readonly
Returns the value of attribute inverse.
-
#navigation_id ⇒ Object
readonly
Returns the value of attribute navigation_id.
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', inverse: false, inline: false, classes: [], html_attributes: {}) ⇒ ServiceNavigationComponent
constructor
A new instance of ServiceNavigationComponent.
- #navigation ⇒ Object
- #navigation_list ⇒ Object
Constructor Details
#initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', inverse: false, inline: false, classes: [], html_attributes: {}) ⇒ ServiceNavigationComponent
Returns a new instance of ServiceNavigationComponent.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 23 def initialize(service_name: nil, service_url: nil, navigation_items: [], current_path: nil, aria_label: "Service information", navigation_id: 'navigation', inverse: false, inline: false, classes: [], html_attributes: {}) @service_name_text = service_name @service_url = service_url @current_path = current_path @aria_label_text = aria_label @navigation_id = @inverse = inverse @inline = inline 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.
21 22 23 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 21 def aria_label_text @aria_label_text end |
#inline ⇒ Object (readonly)
Returns the value of attribute inline.
21 22 23 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 21 def inline @inline end |
#inverse ⇒ Object (readonly)
Returns the value of attribute inverse.
21 22 23 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 21 def inverse @inverse end |
#navigation_id ⇒ Object (readonly)
Returns the value of attribute navigation_id.
21 22 23 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 21 def @navigation_id end |
Instance Method Details
#call ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 41 def call outer_element do safe_join( [ tag.div(class: class_names("#{brand}-width-container", "#{brand}-service-navigation__inlining-container" => inline)) do safe_join( [ content_before, tag.div(class: "#{brand}-service-navigation__container") do safe_join([service_name, ].compact) end, content_after ] ) end ] ) end end |
#navigation ⇒ Object
61 62 63 64 65 66 67 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 61 def return unless tag.nav(aria: { label: "Menu" }, class: "#{brand}-service-navigation__wrapper") do safe_join([, ]) end end |
#navigation_list ⇒ Object
69 70 71 |
# File 'app/components/govuk_component/service_navigation_component.rb', line 69 def tag.ul(safe_join([, *, ]), id: , class: "#{brand}-service-navigation__list") end |