govuk_publishing_components 63.3.0 → 63.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 165109e571c6ba5445e74e15f2be52f24c787509790ad41a4ea88664e9efdb65
4
- data.tar.gz: be9e4eafdc824e8cc3ae4e3ad5829f33a85a4df2e6ad3ac86a0c89fd52a2a084
3
+ metadata.gz: 6accce7654a1f778de97ed1e1c305ea2b61ba6e1cd65c18003179d298075dd1f
4
+ data.tar.gz: 17f5ec5d9b2ce4f0dac0f16cf3de381b575bd8c24ce5a1d295dc264e14203829
5
5
  SHA512:
6
- metadata.gz: a4b8872ec44bbe165d2962f38157b1919f3c6433e13c14a714738bfe001b46cab9ea75d0a6d4e7f8c4fd42f98e8e2a4a3c174ff39e6f8dc1fcdcd2d987613eca
7
- data.tar.gz: 2a6335737c699d6a6c5d397a1149e1e8f30e02dae6ba84f11f49edb41bc69743f26b98d22cde3e227447f4dafc00ac90e754384d307a9041586730fcbf720d9c
6
+ metadata.gz: f747916bfc169df32c1c8bf40630a8c03855c7666b467072cb1a21cd413d1f5ffacb8117b1c051f98402ad90f8ae8c205a2cacfeeded10d52a5dab37031810de
7
+ data.tar.gz: a16291d0bf67efc71960cc73c18d721b7f9d629b72ba23e35dcd3a42e9b84165aa64bb2a5e0817de2826b7175cb5e9adb514bdc7c998201be951226eb51be891
@@ -18,10 +18,6 @@ shared_accessibility_criteria:
18
18
  - link
19
19
  examples:
20
20
  default:
21
- data:
22
- organisation:
23
- name: 'Organisation<br>Name'
24
- with_a_link:
25
21
  data:
26
22
  organisation:
27
23
  name: 'Organisation<br>Name'
@@ -162,6 +158,12 @@ examples:
162
158
  image:
163
159
  url: 'https://assets.publishing.service.gov.uk/media/6850134301d3b0e7b62da740/hmps_25_gov_240x188.png'
164
160
  alt_text: 'HM Prison Service'
161
+ without_a_link:
162
+ data:
163
+ organisation:
164
+ name: Cabinet Office
165
+ brand: cabinet-office
166
+ crest: 'single-identity'
165
167
  as_a_heading:
166
168
  description: The `heading_level` option takes a number from 1 to 6.
167
169
  data:
@@ -4,44 +4,40 @@ module GovukPublishingComponents
4
4
  include ActionView::Helpers
5
5
  include ActionView::Context
6
6
 
7
- def initialize(local_assigns)
8
- raise(ArgumentError, "Component requires an organisation including a name") unless minimum_for_component?(local_assigns)
7
+ attr_reader :name, :url, :crest, :image, :logo_image_src, :logo_image_alt, :hide_underline
9
8
 
9
+ def initialize(local_assigns)
10
10
  @name = local_assigns[:organisation][:name]
11
11
  @url = local_assigns[:organisation][:url]
12
12
  @crest = local_assigns[:organisation][:crest]
13
13
  @image = local_assigns[:organisation][:image] || false
14
14
  if @image
15
- @logo_image_src = local_assigns[:organisation][:image][:url] || nil
16
- @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || nil
15
+ @logo_image_src = local_assigns[:organisation][:image][:url] || false
16
+ @logo_image_alt = local_assigns[:organisation][:image][:alt_text] || false
17
17
  end
18
18
  @hide_underline = local_assigns[:hide_underline] || false
19
19
  end
20
20
 
21
21
  def logo_content
22
- if @image
23
- image_tag(@logo_image_src, alt: @logo_image_alt, class: "gem-c-organisation-logo__image")
22
+ if image
23
+ image_tag(logo_image_src, alt: logo_image_alt, class: "gem-c-organisation-logo__image")
24
24
  else
25
- content_tag("span", @name, class: "gem-c-organisation-logo__name")
25
+ content_tag("span", name, class: "gem-c-organisation-logo__name")
26
26
  end
27
27
  end
28
28
 
29
29
  def logo_container_class
30
- logo_class = %w[gem-c-organisation-logo__container]
31
- logo_class << "gem-c-organisation-logo__link" if @url
32
- logo_class << "gem-c-organisation-logo__link-hide-underline" if @hide_underline
33
- logo_class << "gem-c-organisation-logo__crest gem-c-organisation-logo__crest--#{@crest}" if crest_has_visual_identity?
34
- logo_class.join(" ")
30
+ logo_class = "gem-c-organisation-logo__container"
31
+ logo_class = "#{logo_class} gem-c-organisation-logo__link" if url
32
+ logo_class = "#{logo_class} gem-c-organisation-logo__link-hide-underline" if hide_underline
33
+ logo_class = "#{logo_class} gem-c-organisation-logo__crest gem-c-organisation-logo__crest--#{crest}" if crest_has_visual_identity?
34
+ logo_class
35
35
  end
36
36
 
37
37
  private
38
38
 
39
- def minimum_for_component?(options)
40
- true unless !options[:organisation] || options[:organisation] && !options[:organisation][:name]
41
- end
42
-
43
39
  def crest_has_visual_identity?
44
- @crest.present? && !%w[no-identity custom].include?(@crest)
40
+ crest.present? && !%w[no-identity custom].include?(crest)
45
41
  end
46
42
  end
47
43
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "63.3.0".freeze
2
+ VERSION = "63.3.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 63.3.0
4
+ version: 63.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev