Sha256: 9e86306931534c7c2d0a7c813262a3fa1c421d691efaba53f6af1302f7017f93

Contents?: true

Size: 1 KB

Versions: 375

Compression:

Stored size: 1 KB

Contents

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

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

        @classes = ""
        @classes << heading_size(options[:font_size])
        @classes << " gem-c-heading--mobile-top-margin" if options[:mobile_top_margin]
        @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]
      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

375 entries across 375 versions & 1 rubygems

Version Path
govuk_publishing_components-46.4.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-46.3.1 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-46.3.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-46.2.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-46.1.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-46.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.10.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.9.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.8.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.7.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.6.1 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.6.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.5.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.4.1 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.4.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.3.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.2.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.1.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-45.0.0 lib/govuk_publishing_components/presenters/heading_helper.rb
govuk_publishing_components-44.11.0 lib/govuk_publishing_components/presenters/heading_helper.rb