Sha256: 8280efa51d9084ea7f3095db1fd70cc0852230ca2102f3eecacffdad00ea64e5

Contents?: true

Size: 1.22 KB

Versions: 20

Compression:

Stored size: 1.22 KB

Contents

require_relative '../base'

module CCS
  module Components
    module GovUK
      # = GOV.UK Hint
      #
      # This is used to generate the hint text component from the Government Design Systems
      #
      # @!attribute [r] text
      #   @return [String] Text for the hint

      class Hint < Base
        private

        attr_reader :text

        public

        # @param text [String] the hint text.
        #                      If nil, then a block will be rendered
        # @param options [Hash] options that will be used in customising the HTML
        #
        # @option options [String] :classes additional CSS classes for the hint HTML
        # @option options [Hash] :attributes ({}) any additional attributes that will added as part of the HTML

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

          @text = text
        end

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

        def render
          tag.div(**options[:attributes]) do
            text || yield
          end
        end

        # The default attributes for the hint

        DEFAULT_ATTRIBUTES = { class: 'govuk-hint' }.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/hint.rb
ccs-frontend_helpers-2.0.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.2.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.1.2 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.1.1 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.1.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.1.0.beta0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-1.0.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.5.0.beta1 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.5.0.beta0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.3.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.2.0 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.2 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.1 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.1.rc.1 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.0.rc.7 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.0.rc.6 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.0.rc.5 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.0.rc.4 lib/ccs/components/govuk/hint.rb
ccs-frontend_helpers-0.1.0.rc.3 lib/ccs/components/govuk/hint.rb