Sha256: e2128099f06df43b378561bb60eae164db9712dee5d84e1cbe43760076c3ae78

Contents?: true

Size: 820 Bytes

Versions: 7

Compression:

Stored size: 820 Bytes

Contents

# frozen_string_literal: true

require "govuk_design_system_formbuilder"

module Katalyst
  module GOVUK
    module Formbuilder
      module Traits
        # Extend GovukDesignSystemFormBuilder::Traits::Label set the default size to small for non-nested labels.
        module Label
          extend ActiveSupport::Concern

          included do
            private

            def label_content
              default = @builder.fieldset_context.count.positive? ? {} : { size: "s" }

              case @label
              when Hash
                default.merge(@label)
              when Proc
                default.merge(content: @label)
              else
                fail(ArgumentError, %(label must be a Proc or Hash))
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
katalyst-govuk-formbuilder-1.13.0 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.12.1 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.12.0 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.11.0 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.10.2 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.10.1 lib/katalyst/govuk/formbuilder/traits/label.rb
katalyst-govuk-formbuilder-1.10.0 lib/katalyst/govuk/formbuilder/traits/label.rb