Class: CCS::Components::GovUK::SkipLink

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

Overview

GOV.UK Skip Link

This is used to generate the skip link component from the GDS - Components - Skip link

Constant Summary collapse

DEFAULT_ATTRIBUTES =

The default attributes for the skip link

{ class: 'govuk-skip-link', data: { module: 'govuk-skip-link' } }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(text:, href: nil, **options) ⇒ SkipLink

Returns a new instance of SkipLink.

Parameters:

  • text (String)

    the text for the skip link

  • href (String) (defaults to: nil)

    the href for the skip link

  • options (Hash)

    options that will be used in customising the HTML

Options Hash (**options):

  • :classes (String)

    additional CSS classes for the skip link HTML

  • :attributes (Hash) — default: {}

    any additional attributes that will added as part of the HTML



30
31
32
33
34
35
# File 'lib/ccs/components/govuk/skip_link.rb', line 30

def initialize(text:, href: nil, **options)
  super(**options)

  @text = text
  @href = href || '#content'
end

Instance Method Details

#renderActiveSupport::SafeBuffer

Generates the HTML for the GOV.UK Skip link component

Returns:

  • (ActiveSupport::SafeBuffer)


41
42
43
# File 'lib/ccs/components/govuk/skip_link.rb', line 41

def render
  link_to(text, href, **options[:attributes])
end