Class: CCS::Components::GovUK::Footer::Meta

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/ccs/components/govuk/footer/meta.rb

Overview

GOV.UK Footer Meta

The footer meta section

Instance Method Summary collapse

Constructor Details

#initialize(context:, items: nil, visually_hidden_title: nil, text: nil) ⇒ Meta

Returns a new instance of Meta.

Parameters:

  • items (Array<Hash>) (defaults to: nil)

    an array of links for the meta section. See Link#initialize for details of the items in the array.

  • visually_hidden_title (String) (defaults to: nil)

    (‘Support links’) title for the meta section

  • text (String) (defaults to: nil)

    text to add to the meta section of the footer

  • context (ActionView::Base)

    the view context



34
35
36
37
38
# File 'lib/ccs/components/govuk/footer/meta.rb', line 34

def initialize(context:, items: nil, visually_hidden_title: nil, text: nil)
  @meta_links = items&.map { |meta_link| Link.new(li_class: 'govuk-footer__inline-list-item', context: context, **meta_link) }
  @visually_hidden_title = visually_hidden_title || 'Support links'
  @text = text
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Footer Meta sections

Returns:

  • (ActiveSupport::SafeBuffer)


44
45
46
47
48
49
50
51
52
53
54
# File 'lib/ccs/components/govuk/footer/meta.rb', line 44

def render
  capture do
    concat(tag.h2(visually_hidden_title, class: 'govuk-visually-hidden'))
    if meta_links.present?
      concat(tag.ul(class: 'govuk-footer__inline-list') do
        meta_links.each { |meta_link| concat(meta_link.render) }
      end)
    end
    concat(tag.div(text, class: 'govuk-footer__meta-custom')) if text
  end
end