Class: GovukPublishingComponents::Presenters::OrganisationLogoHelper

Inherits:
Object
  • Object
show all
Includes:
ActionView::Context, ActionView::Helpers
Defined in:
lib/govuk_publishing_components/presenters/organisation_logo_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_assigns) ⇒ OrganisationLogoHelper

Returns a new instance of OrganisationLogoHelper.



9
10
11
12
13
14
15
16
17
18
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 9

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

Instance Attribute Details

#crestObject (readonly)

Returns the value of attribute crest.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def crest
  @crest
end

#imageObject (readonly)

Returns the value of attribute image.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def image
  @image
end

#logo_image_altObject (readonly)

Returns the value of attribute logo_image_alt.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def logo_image_alt
  @logo_image_alt
end

#logo_image_srcObject (readonly)

Returns the value of attribute logo_image_src.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def logo_image_src
  @logo_image_src
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def name
  @name
end

#urlObject (readonly)

Returns the value of attribute url.



7
8
9
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 7

def url
  @url
end

Instance Method Details

#logo_container_classObject



28
29
30
31
32
33
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 28

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

#logo_contentObject



20
21
22
23
24
25
26
# File 'lib/govuk_publishing_components/presenters/organisation_logo_helper.rb', line 20

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