Sha256: be7841a2853dc6ac6afeebc28750be065e2d84ddd68336603e0ab5ad8705d761

Contents?: true

Size: 992 Bytes

Versions: 8

Compression:

Stored size: 992 Bytes

Contents

module GovukPublishingComponents
  module Presenters
    class HeadingHelper
      attr_reader :heading_tag, :id, :classes, :heading_classes

      def initialize(options)
        @id = options[:id]

        @classes = ""
        @classes << " gem-c-heading--padding" if options[:padding]
        @classes << " gem-c-heading--border-top-#{options[:border_top]}" if [1, 2, 5].include? options[:border_top]
        @classes << " gem-c-heading--inverse" if options[:inverse]

        @heading_classes = "gem-c-heading__text #{heading_size(options[:font_size])}"
      end

    private

      def heading_size(option)
        gem_class = "gem-c-heading--font-size-"
        govuk_class = "govuk-heading-"

        case option
        when "xl"
          "#{govuk_class}xl"
        when "l"
          "#{govuk_class}l"
        when 24, "m"
          "#{govuk_class}m"
        when 19, "s"
          "#{govuk_class}s"
        else
          "#{gem_class}27"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
govuk_publishing_components-51.1.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-51.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-50.0.1 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-50.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-49.1.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-49.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-48.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-47.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb