Sha256: cb47af2bb8650342637243bd1422107336c619ceb382d1cdf3bb7ff1a6c43f15

Contents?: true

Size: 1.46 KB

Versions: 20

Compression:

Stored size: 1.46 KB

Contents

require_relative '../base'

module CCS
  module Components
    module GovUK
      # = GOV.UK Skip Link
      #
      # This is used to generate the skip link component from the
      # {https://design-system.service.gov.uk/components/skip-link GDS - Components - Skip link}
      #
      # @!attribute [r] text
      #   @return [String] Text for the skip link
      # @!attribute [r] href
      #   @return [String] The href for the skip link

      class SkipLink < Base
        private

        attr_reader :text, :href

        public

        # @param text [String] the text for the skip link
        # @param href [String] the href for the skip link
        # @param options [Hash] options that will be used in customising the HTML
        #
        # @option options [String] :classes additional CSS classes for the skip link HTML
        # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML

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

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

        # Generates the HTML for the GOV.UK Skip link component
        #
        # @return [ActiveSupport::SafeBuffer]

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

        # The default attributes for the skip link

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ccs-frontend_helpers-2.1.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.3.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/skip_link.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/skip_link.rb