Sha256: d37ea26c7c7f0f7f0a3226f68a2001682cf54020ef87d0e3d2bec68100560dc9

Contents?: true

Size: 1.95 KB

Versions: 8

Compression:

Stored size: 1.95 KB

Contents

require_relative '../../../base'

module CCS
  module Components
    module GovUK
      class SummaryList < Base
        class Action
          # = GOV.UK Summary list action link
          #
          # @!attribute [r] text
          #   @return [String] Text for the action link
          # @!attribute [r] href
          #   @return [String] The href for the action link
          # @!attribute [r] visually_hidden_text
          #   @return [String] Visually hidden text for the action link

          class Link < Base
            private

            attr_reader :text, :href, :visually_hidden_text

            public

            # @param text [String] the text for the action link
            # @param href [String] the href for the action link
            # @param visually_hidden_text [String] optional visually hidden text for the action link
            # @param options [Hash] options that will be used in customising the HTML
            #
            # @option options [String] :classes additional CSS classes for the summary list action link HTML
            # @option options [Hash] :attributes any additional attributes that will added as part of the HTML

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

              @text = text
              @href = href
              @visually_hidden_text = visually_hidden_text
            end

            # Generates the HTML for the GOV.UK Summary list action link
            #
            # @return [ActiveSupport::SafeBuffer]

            def render
              link_to(href, **@options[:attributes]) do
                concat(text)
                concat(tag.span(visually_hidden_text, class: 'govuk-visually-hidden')) if visually_hidden_text
              end
            end

            # The default attributes for the summary list action link

            DEFAULT_ATTRIBUTES = { class: 'govuk-link' }.freeze
          end
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/summary_list/action/link.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/summary_list/action/link.rb