Sha256: 30815fc7f6d627b44355c5149282f3b7fd933746171dd873c03af7b9bb969578

Contents?: true

Size: 1.42 KB

Versions: 8

Compression:

Stored size: 1.42 KB

Contents

module GovukPublishingComponents
  module Presenters
    class OrganisationLogoHelper
      include ActionView::Helpers
      include ActionView::Context

      attr_reader :name, :url, :crest, :image, :logo_image_src, :logo_image_alt, :hide_underline

      def initialize(local_assigns)
        @name = local_assigns[:organisation][:name]
        @url = local_assigns[:organisation][:url]
        @crest = local_assigns[:organisation][:crest]
        @image = local_assigns[:organisation][:image] || false
        if @image
          @logo_image_src = local_assigns[:organisation][:image][:url] || false
          @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
        end
        @hide_underline = local_assigns[:hide_underline] || false
      end

      def logo_content
        if image
          image_tag(logo_image_src, alt: logo_image_alt, class: "gem-c-organisation-logo__image")
        else
          content_tag("span", name, class: "gem-c-organisation-logo__name")
        end
      end

      def logo_container_class
        logo_class = "gem-c-organisation-logo__container"
        logo_class = "#{logo_class} gem-c-organisation-logo__link" if url
        logo_class = "#{logo_class} gem-c-organisation-logo__link-hide-underline" if hide_underline
        logo_class = "#{logo_class} gem-c-organisation-logo__crest gem-c-organisation-logo__crest--#{crest}" if crest
        logo_class
      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/organisation_logo_helper.rb
govuk_publishing_components-51.0.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-50.0.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-50.0.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-49.1.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-49.0.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-48.0.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-47.0.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb