Sha256: a1408bdd3fb4dcc5915594b04c9f302bfccd2c9d7ca1c4d3ed85b152b031f10a

Contents?: true

Size: 887 Bytes

Versions: 9

Compression:

Stored size: 887 Bytes

Contents

module GOVUKDesignSystemFormBuilder
  module Elements
    class Hint < GOVUKDesignSystemFormBuilder::Base
      def initialize(builder, object_name, attribute_name, text, value = nil, radio: false, checkbox: false)
        super(builder, object_name, attribute_name)

        @value          = value
        @hint_text      = text
        @radio_class    = radio_class(radio)
        @checkbox_class = checkbox_class(checkbox)
      end

      def html
        return nil if @hint_text.blank?

        @builder.tag.span(@hint_text, class: hint_classes, id: hint_id)
      end

    private

      def hint_classes
        %w(govuk-hint).push(@radio_class, @checkbox_class).compact
      end

      def radio_class(radio)
        radio ? 'govuk-radios__hint' : nil
      end

      def checkbox_class(checkbox)
        checkbox ? 'govuk-checkboxes__hint' : nil
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
govuk_design_system_formbuilder-0.9.7 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.6 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.5 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.4 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.3 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.2 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.1 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.9.0 lib/govuk_design_system_formbuilder/elements/hint.rb
govuk_design_system_formbuilder-0.7.10 lib/govuk_design_system_formbuilder/elements/hint.rb