Sha256: 6168b0f8d12f0b127a659df049876ab2794098ac459944bb3d8fdd4f8179d0f2

Contents?: true

Size: 1.25 KB

Versions: 232

Compression:

Stored size: 1.25 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
        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")
        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

232 entries across 232 versions & 1 rubygems

Version Path
govuk_publishing_components-21.27.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.27.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.26.2 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.26.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.26.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.25.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.24.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.23.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.23.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.22.2 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.22.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.22.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.21.3 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.21.2 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.21.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.21.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.20.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.19.1 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.19.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb
govuk_publishing_components-21.18.0 lib/govuk_publishing_components/presenters/organisation_logo_helper.rb