Class: CCS::Components::GovUK::Header

Inherits:
Base
  • Object
show all
Defined in:
lib/ccs/components/govuk/header.rb

Overview

GOV.UK Header

This is used to generate the header component from the GDS - Components - Header

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the breadcrumbs

{ class: 'govuk-header' }.freeze

Instance Method Summary collapse

Constructor Details

#initializeHeader

Returns a new instance of Header.

Parameters:

  • navigation (Hash)

    options for the navigation section of the header. See Navigation#initialize for details of the options.

  • menu_button (Hash)

    options for the menu button in the header. See Navigation#initialize for details of the options.

  • service (Hash)

    options for the service name

  • options (Hash)

    options that will be used in customising the HTML



42
43
44
45
46
47
48
49
# File 'lib/ccs/components/govuk/header.rb', line 42

def initialize(**)
  super

  @options[:container_classes] ||= 'govuk-width-container'
  @options[:homepage_url] ||= '//gov.uk'

  @logo = Logo.new(classes: 'govuk-header__logotype', attributes: { aria: { label: 'GOV.UK' } }, context: @context)
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Header component

Returns:

  • (ActiveSupport::SafeBuffer)


55
56
57
58
59
60
61
# File 'lib/ccs/components/govuk/header.rb', line 55

def render
  tag.div(**options[:attributes]) do
    tag.div(class: "govuk-header__container #{options[:container_classes]}") do
      concat()
    end
  end
end