Class: CCS::Components::GovUK::Header::Navigation
- Inherits:
-
Object
- Object
- CCS::Components::GovUK::Header::Navigation
- Includes:
- ActionView::Context, ActionView::Helpers
- Defined in:
- lib/ccs/components/govuk/header/navigation.rb
Overview
GOV.UK Header navigation
The header navigation section
Instance Method Summary collapse
-
#initialize(navigation:, context:, menu_button: nil) ⇒ Navigation
constructor
A new instance of Navigation.
-
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Navigation.
Constructor Details
#initialize(navigation:, context:, menu_button: nil) ⇒ Navigation
Returns a new instance of Navigation.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ccs/components/govuk/header/navigation.rb', line 44 def initialize(navigation:, context:, menu_button: nil) ||= {} [:text] ||= 'Menu' [:aria] = { controls: 'navigation' } [:aria][:label] = [:label] if [:label] @menu_button = @navigation_links = [:items].map { || Link.new(context: context, **) } @navigation_label = [:label] || [:text] @navigation_classes = "govuk-header__navigation #{[:classes]}".rstrip end |
Instance Method Details
#render ⇒ ActiveSupport::SafeBuffer
Generates the HTML for the GOV.UK Navigation
61 62 63 64 65 66 67 68 |
# File 'lib/ccs/components/govuk/header/navigation.rb', line 61 def render tag.nav(aria: { label: }, class: ) do concat(([:text], type: :button, class: 'govuk-header__menu-button govuk-js-header-toggle', aria: [:aria], hidden: true)) concat(tag.ul(id: 'navigation', class: 'govuk-header__navigation-list') do .each { || concat(.render) } end) end end |