Sha256: 14c457675f9f2633ed46ee60040659b2d12c289f8522a048c77f312f3c630ce7

Contents?: true

Size: 1.3 KB

Versions: 2

Compression:

Stored size: 1.3 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

      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
        @lang = local_assigns[:lang] || nil
        if @image
          @logo_image_src = local_assigns[:organisation][:image][:url] || false
          @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
        end
      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", lang: @lang)
        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__crest gem-c-organisation-logo__crest--#{crest}" if crest
        logo_class
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
govuk_publishing_components-21.66.4 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.66.3 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb